Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #9827] Add basic auth support to download raw yml config from private repo #9828

Merged
merged 3 commits into from Jun 9, 2021

Conversation

AirWick219
Copy link
Contributor

@AirWick219 AirWick219 commented May 26, 2021

This PR adds Token auth support so that users can inherit shared config from the internal private repo.

This addresses #9827


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@AirWick219 AirWick219 changed the title Add Token auth support to download raw yml config from private repo [Fix #9827] Add Token auth support to download raw yml config from private repo May 27, 2021
Copy link
Member

@dvandersluis dvandersluis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some tests for this feature please?

Copy link
Member

@koic koic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new feature. So it will be merged when we can confirm that the next release is not a bugfix release. Thank you.

@@ -55,6 +55,7 @@ def request(uri = @uri, limit = 10, &block)
def generate_request(uri)
request = Net::HTTP::Get.new(uri.request_uri)

request['Authorization'] = "token #{uri.user}" if uri.user
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this really should be Github specific. A Personal Access Token (PAT) can be used in Github using basic auth - which is the syntax suggested here where the user field of the URL is the PAT. Should this line be removed and set the user on the request object like this?

request.basic_auth(uri.user, uri.password) if uri.user

I tested some sample code and this works for Github using a PAT and should work for any URL that supports basic auth.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O cool. That works. Didn't know PAT works with basic auth. Thanks

@AirWick219 AirWick219 changed the title [Fix #9827] Add Token auth support to download raw yml config from private repo [Fix #9827] Add Basic auth support to download raw yml config from private repo Jun 3, 2021
@AirWick219 AirWick219 changed the title [Fix #9827] Add Basic auth support to download raw yml config from private repo [Fix #9827] Add basic auth support to download raw yml config from private repo Jun 3, 2021
@AirWick219
Copy link
Contributor Author

@dvandersluis and @koic Let me know if you guys are good with the changes

@bbatsov bbatsov merged commit 5d6c085 into rubocop:master Jun 9, 2021
@AirWick219 AirWick219 deleted the support_token_auth branch June 14, 2021 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants