Skip to content

Commit

Permalink
core: add missing prefix property to auth backend
Browse files Browse the repository at this point in the history
ref oras-project#164 (comment)

Signed-off-by: tarilabs <matteo.mortari@gmail.com>
  • Loading branch information
tarilabs committed Oct 17, 2024
1 parent 36ef98a commit 7092f16
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
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, prefix="https", **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 = prefix
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"

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, self.prefix)

def __repr__(self) -> str:
return str(self)
Expand Down

0 comments on commit 7092f16

Please sign in to comment.