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

Adds support for base64 and OAuth bearer tokens #24

Merged
merged 2 commits into from
May 25, 2023
Merged

Conversation

jimisola
Copy link
Contributor

This MR adds support for:

  1. base64-encoded "username:password" tokens
  2. OAuth bearer tokens

I've also:

  • changed parsing library to argparse

  • added Utils class

  • removed all relative import (the try-import with sys.path.append in main.py is to allow the main.py to be run directly when developing)

  • Done regression tests (there is a unit test for non-auth download).

  • manually tested base64-encoded "username:password" tokens

  • NOTE: OAuth bearer token has not been tested because I have no easy way of testing it (Nexus does not support OAuth and I'm not aware of any GitLab och GitHub Maven repos to test with). My colleague has reviewed the code. A note in the changelog about the feature not being tested would be good.

Closes: #23

headers["Authorization"] = "Basic " + base64.b64encode(token.encode()).decode()
headers["Authorization"] = f"Basic {base64.b64encode(token.encode()).decode()}"
elif Utils.is_base64(self.password):
headers["Authorization"] = f"Basic {self.password}"
Copy link
Owner

Choose a reason for hiding this comment

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

perhaps we should allow users to specify the Authorization header directly here.
Then we dont have to care about what users actually auths with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that there is a need. This works with basic auth and OAuth. If there is a need then we can add it.
But, I rather not add things that might be used.

@hamnis
Copy link
Owner

hamnis commented May 25, 2023

@jimisola needs a format then I'll merge it

@jimisola
Copy link
Contributor Author

@jimisola needs a format then I'll merge it

Too many context changes today. Fixed it now. Thanks.

@hamnis hamnis merged commit 7b2a88f into hamnis:main May 25, 2023
@hamnis
Copy link
Owner

hamnis commented May 25, 2023

@jimisola released as 0.3.1

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.

Support authentication using token (OAuth)
2 participants