Skip to main content

Module security

Module security 

Source
Expand description

Authentication, authorization, CSRF, and password hashing.

Structs§

AccessDecisionManager
Collects voters and applies an affirmative strategy (any grant wins; any deny without grant fails).
Argon2idPasswordHasher
Argon2id hasher using the crate defaults (PHC string output).
AsyncSessionTokenMiddleware
Async variant of SessionTokenMiddleware.
AuthorizationRequest
Authorization redirect URL plus CSRF state and PKCE code_verifier.
CsrfToken
Issued CSRF token: intention id + opaque value for the form field.
FirewallMiddleware
Firewall that reads a header, runs an Authenticator, and stores the token on the request.
HmacCsrfTokenManager
HMAC-SHA256 CSRF manager. Secret must be app-owned and stable across requests.
InMemoryUser
Simple in-memory user for apps and tests.
LdapAuthenticator
Firewall Authenticator that expects username:password in the credentials string.
LdapBindConfig
Connection / DN templates for an LDAP bind authenticator.
LdapIdentity
Identity returned after a successful directory bind.
MockLdapBinder
Fixed-response binder for tests.
MockTokenExchanger
Fixed-response exchanger for tests.
OAuthClientConfig
OAuth 2.0 / OIDC client (relying party) settings.
OAuthTokenResponse
Parsed token-endpoint JSON body.
RoleVoter
Grants when the token is authenticated and holds role.
SessionTokenMiddleware
Sync middleware: restore session identity onto _security_token when absent.
UsernamePasswordToken
Username/password-style token (also used for bearer/API key strings).

Enums§

SecurityError
AuthN/Z and CSRF failure.
Vote
Affirmative / deny / abstain vote.

Constants§

CSRF_FIELD_NAME
Default HTML form field name for the CSRF token (Symfony _token).
LDAP_USERNAME_PLACEHOLDER
Placeholder token replaced by LdapBindConfig::user_dn.
SECURITY_SESSION_KEY
Session attribute key for the serialized security identity.
TOKEN_ATTRIBUTE
Request attribute key where the firewall stores the security token.

Traits§

Authenticator
Turns request credentials into a UsernamePasswordToken.
CsrfTokenManager
Issues and validates CSRF tokens.
LdapBinder
Sync LDAP bind. Apps implement this with their LDAP client.
PasswordHasher
Hashes and verifies password strings.
TokenExchanger
Sync token exchange. Apps implement this with their HTTP stack.
TokenInterface
Security token carrying credentials and optional user.
UserInterface
Authenticated (or anonymous) principal.
Voter
Decides access for a token against a subject.

Functions§

authenticate_ldap_password
Binds then maps to a UsernamePasswordToken.
build_authorization_request
Builds an authorization request with a fresh random state and PKCE verifier.
build_authorization_request_with
Builds an authorization request with caller-supplied state and PKCE verifier.
decode_jwt_payload_json
Decodes the JWT payload segment without verifying the signature.
login
Stores an authenticated token in session (user id + roles only; no credentials).
logout
Removes the security identity from session.
parse_token_response
Parses a token-endpoint JSON response body.
request_token
Returns the firewall token from request attributes when present.
split_user_password
Splits username:password (first colon). Password may contain colons.
subject_from_id_token
Reads the OIDC sub claim from an unverified ID token payload.
token_exchange_form
application/x-www-form-urlencoded body for the authorization-code token exchange.
token_from_ldap_identity
Builds an authenticated security token from a successful LDAP identity.
token_from_oidc_subject
Builds an authenticated security token from an IdP subject and roles.
token_from_session
Restores a token from session when a valid identity is stored.

Type Aliases§

Subject
Subject of an access check (attribute string in v0).