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

core: add missing prefix property to auth backend #165

Merged
merged 3 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
The versions coincide with releases on pip. Only major versions will be released as tags on Github.

## [0.0.x](https://github.com/oras-project/oras-py/tree/main) (0.0.x)
- add missing prefix property to auth backend (0.2.23)
- allow for filepaths to include `:` (0.2.22)
- release request (0.2.21)
- add missing basic auth data for request token function in token auth backend (0.2.2)
Expand Down
3 changes: 2 additions & 1 deletion oras/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ class AuthenticationException(Exception):
pass


def get_auth_backend(name="token", session=None, **kwargs):
def get_auth_backend(name="token", session=None, insecure=False, **kwargs):
backend = auth_backends.get(name)
if not backend:
raise ValueError(f"Authentication backend {backend} is not known.")
backend = backend(**kwargs)
backend.session = session or requests.Session()
backend.prefix = "http" if insecure else "https"
return backend
1 change: 1 addition & 0 deletions oras/auth/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AuthBackend:

def __init__(self, *args, **kwargs):
self._auths: dict = {}
self.prefix: str = "https"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

step 4.

the base AuthBackend by default would have a property prefix valorized to https, but as we just seen in step 3, this is set to the actual prefix value.


def get_auth_header(self):
raise NotImplementedError
Expand Down
2 changes: 1 addition & 1 deletion oras/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(
self.session.cookies.set_policy(DefaultCookiePolicy(allowed_domains=[]))

# Get custom backend, pass on session to share
self.auth = oras.auth.get_auth_backend(auth_backend, self.session)
self.auth = oras.auth.get_auth_backend(auth_backend, self.session, insecure)

def __repr__(self) -> str:
return str(self)
Expand Down
2 changes: 1 addition & 1 deletion oras/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__copyright__ = "Copyright The ORAS Authors."
__license__ = "Apache-2.0"

__version__ = "0.2.22"
__version__ = "0.2.23"
AUTHOR = "Vanessa Sochat"
EMAIL = "vsoch@users.noreply.github.com"
NAME = "oras"
Expand Down
Loading