Skip to content

Commit 6df6127

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

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
1414
The versions coincide with releases on pip. Only major versions will be released as tags on Github.
1515

1616
## [0.0.x](https://github.com/oras-project/oras-py/tree/main) (0.0.x)
17+
- add missing prefix property to auth backend (0.2.23)
1718
- allow for filepaths to include `:` (0.2.22)
1819
- release request (0.2.21)
1920
- add missing basic auth data for request token function in token auth backend (0.2.2)

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, insecure=False, **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 = "http" if insecure else "https"
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, insecure)
8282

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

oras/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__copyright__ = "Copyright The ORAS Authors."
33
__license__ = "Apache-2.0"
44

5-
__version__ = "0.2.22"
5+
__version__ = "0.2.23"
66
AUTHOR = "Vanessa Sochat"
77
88
NAME = "oras"

0 commit comments

Comments
 (0)