Skip to content

Commit 7092f16

Browse files
committed
core: add missing prefix property to auth backend
ref #164 (comment) Signed-off-by: tarilabs <[email protected]>
1 parent 36ef98a commit 7092f16

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

oras/auth/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class AuthenticationException(Exception):
1414
pass
1515

1616

17-
def get_auth_backend(name="token", session=None, **kwargs):
17+
def get_auth_backend(name="token", session=None, prefix="https", **kwargs):
1818
backend = auth_backends.get(name)
1919
if not backend:
2020
raise ValueError(f"Authentication backend {backend} is not known.")
2121
backend = backend(**kwargs)
2222
backend.session = session or requests.Session()
23+
backend.prefix = prefix
2324
return backend

oras/auth/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class AuthBackend:
1919

2020
def __init__(self, *args, **kwargs):
2121
self._auths: dict = {}
22+
self.prefix: str = "https"
2223

2324
def get_auth_header(self):
2425
raise NotImplementedError

oras/provider.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(
7878
self.session.cookies.set_policy(DefaultCookiePolicy(allowed_domains=[]))
7979

8080
# Get custom backend, pass on session to share
81-
self.auth = oras.auth.get_auth_backend(auth_backend, self.session)
81+
self.auth = oras.auth.get_auth_backend(auth_backend, self.session, self.prefix)
8282

8383
def __repr__(self) -> str:
8484
return str(self)

0 commit comments

Comments
 (0)