Source code for oras.auth
import requests
from .basic import BasicAuth
from .token import TokenAuth
auth_backends = {"token": TokenAuth, "basic": BasicAuth}
[docs]
class AuthenticationException(Exception):
"""
An exception to raise when Authentication errors are fatal
"""
pass
[docs]
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