Principal (bearer and basic)
rn_forge.django.auth.drf.principal
Bind rn_forge.auth principal authentication to DRF requests.
PrincipalBasicAuthentication
Bases: _PrincipalAuthentication
Authenticate HTTP Basic (RFC 7617) into a :class:rn_forge.auth.Principal.
Intended for local development and simple internal deployments. The authenticator receives the base64 credential exactly as sent.
get_authenticator()
Return the authenticator to verify with: the authenticator attribute.
Override to build one lazily, as JWKSBearerAuthentication does.
link_principal(principal)
Return principal as the caller to act as.
PrincipalBearerAuthentication
Bases: _PrincipalAuthentication
Authenticate Authorization: Bearer <token> into a :class:rn_forge.auth.Principal.
Subclass and set authenticator, accounts, contexts and,
optionally, realm and scope_map.
The verified token's (issuer, subject) is looked up with
accounts.lookup, which never provisions. A token with no linked
account, or whose account is inactive, is a 401. The principal's
subject is then the account ID (external_subject keeps the token's),
its roles, tenant and attributes come from the account's authorization
context, and its permissions are the context's limited by the token's
scopes through scope_map (a scope the map does not name allows nothing).
get_authenticator()
Return the authenticator to verify with: the authenticator attribute.
Override to build one lazily, as JWKSBearerAuthentication does.
requires(requirement, *, authorizer=None)
Return a DRF permission class enforcing requirement on the principal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requirement
|
Requirement
|
The scopes and roles demanded. |
required |
authorizer
|
Authorizer | None
|
Defaults to :class: |
None
|