Skip to content

xtr_security

The xtr security bundle: the family facade and the container wiring.

This is the bundle package of the xtr security family. It holds the :class:Security facade, and the :class:~xtr_security.bundle.SecurityBundle that configures :mod:xtr_security_core, :mod:xtr_security_http and :mod:xtr_password_hasher from one :class:~xtr_security.bundle.SecurityConfig.

OidcBackChannelLogoutHandler

OidcBackChannelLogoutHandler(logout: OidcBackChannelLogout)

Answers a provider's pushed logout token with the status it amounts to.

The bundle registers one per OIDC firewall whose back-channel logout is enabled, qualified by the firewall's name — the handler is the provider's to reach and the application's to map, and two providers push to two firewalls' routes.

Record what verifies the pushed token and writes its session end down.

Parameters:

  • logout (OidcBackChannelLogout) –

    Verifies the logout token against the provider's keys and records the session it names as ended.

Security

Security(token_storage: TokenStorageInterface, authorization_checker: AuthorizationCheckerInterface)

Bases: AuthorizationCheckerInterface, GuestAuthorizationCheckerInterface

One object for the two everyday questions: who is calling, and may they.

A thin front over the token storage and the authorization checker, so a controller or a service asks security.get_user() and await security.is_granted(...) without wiring both. It is itself an authorization checker — for the current caller and for a given user alike — so it stands in wherever one is wanted.

Record where the current token lives and who answers authorization.

get_token

get_token() -> TokenInterface | None

Return the current token, or None when nobody is authenticated.

get_user

get_user() -> UserInterface | None

Return the current user, or None when nobody is authenticated.

is_granted async

is_granted(attribute: object, subject: object = None, access_decision: AccessDecision | None = None) -> bool

Tell whether the current caller may have attribute over subject.

is_granted_for_user async

is_granted_for_user(user: UserInterface | None, attribute: object, subject: object = None, access_decision: AccessDecision | None = None) -> bool

Tell whether user — or a guest, for None — may have attribute.

Raises:

  • UnsupportedUserError –

    When the checker cannot decide for a given user rather than only the current caller.

deny_access_unless_granted async

deny_access_unless_granted(attribute: object, subject: object = None, message: str = 'Access Denied.') -> None

Raise unless the current caller may have attribute over subject.

Raises:

  • AccessDeniedError –

    When access is not granted, carrying the decision that refused so a handler can explain it.