oso.framework.auth namespace¶
Submodules¶
oso.framework.auth.common module¶
Common Authentication Types.
- class oso.framework.auth.common.AuthConfig(*, parsers: ~collections.abc.Sequence[~oso.framework.auth.common.BaseParserConfig] = <factory>)[source]¶
Bases:
AutoLoadConfig
,_parsers
Container for parser configs.
- parsers¶
Parser configs, discriminated by type.
- Type:
- class oso.framework.auth.common.AuthParser(*args, **kwargs)[source]¶
Bases:
Protocol
Required Parser implementation details.
- parse(request: Request) AuthResult [source]¶
Parse a given request into an
AuthResult
.- Parameters:
request (flask.Request) – Incoming request.
- Returns:
The authentication result.
- Return type:
- parse_allowlist(allowlist: list[str]) list[Any] [source]¶
Parse input allowlist.
Given an allowlist configuration, parse it into a format that
RequireAuth()
can utilize to raiseHTTP 403: Forbidden
.- Parameters:
allowlist (list[str]) – Input configuration as a list of strings.
- Returns:
A list of allowed users to compare a request’s
AuthResult._user
to.- Return type:
- class oso.framework.auth.common.AuthResult[source]¶
Bases:
TypedDict
Parser’s authentication result.
- class oso.framework.auth.common.BaseParserConfig(*, type: ImportString, allowlist: Annotated[Mapping[str, Sequence[str]], Json])[source]¶
Bases:
ImportableConfig
A parser’s base configuration.
- allowlist¶
A mapping of allowlist keys to allowlist filter values. Loaded from envvar the key should be in the format of
AUTH_name_ALLOWLIST_key
, and the value should be in the format of a JSON object.- Type:
oso.framework.auth.extension module¶
Authentication Flask Extension.
- class oso.framework.auth.extension.AuthExtension(config: AuthConfig)[source]¶
Bases:
object
Authentication Extension.
An extension to manage authentication states for flask.Flask applications.
- Parameters:
config (.common.AuthConfig) – Configuration with all parsers defined.
- oso.framework.auth.extension.RequireAuth(handler_name: str, allowlist: str, *allowlists: str) Callable [source]¶
Mark an endpoint as requiring authentication.
- oso.framework.auth.extension.current_auth_ext() AuthExtension [source]¶
Get Current Authentication Extension.
- Returns:
The current authentication extension registered to the flask.Flask application.
- Return type:
.AuthExtension
oso.framework.auth.mtls module¶
mTLS (Mutual Transport Layer Security) Authentication Handler.
- oso.framework.auth.mtls.HEADER_SSL_VERIFY¶
Constant equal to
X-SSL-VERIFY
header key. This header’s value should be set by the TLS terminator, with a MTLS.SSL_VERIFY_SUCCESS value being authorized.- Type:
- oso.framework.auth.mtls.HEADER_SSL_CERT¶
Constant equal to
X-SSL-CERT
header key. This header’s value should be set by the TLS terminator, with a url-encoded certificate string.- Type:
- oso.framework.auth.mtls.SSL_VERIFY_SUCCESS¶
Constant equal to
SUCCESS
. This is the authorized value.- Type:
- oso.framework.auth.mtls.SSL_VERIFY_MISSING¶
Constant equal to
FAILED: Header missing from request
. This is the default header value.- Type:
- oso.framework.auth.mtls.OPENSSH_FINGERPRINT_HEADER¶
Constant equal to
SHA256:
, which is the prefix for the OpenSSH fingerprint type.- Type:
- oso.framework.auth.mtls.MD5_FINGERPRINT_HEADER¶
Constant equal to
MD5:
, which is the prefix for the MD5 fingerprint type.- Type:
- oso.framework.auth.mtls.parse_allowlist(allowlist: list[str]) list[bytes] [source]¶
Parse allowlist.