uxf / security
Requires
- php: ^8.4
- ext-json: *
- ext-openssl: *
- doctrine/dbal: ^4.5
- doctrine/orm: ^3.7
- firebase/php-jwt: ^6.0 || ^7.0
- symfony/config: ^7.4 || ^8.0
- symfony/console: ^7.4 || ^8.0
- symfony/dependency-injection: ^7.4 || ^8.0
- symfony/event-dispatcher: ^7.4 || ^8.0
- symfony/http-client: ^7.4 || ^8.0
- symfony/http-foundation: ^7.4 || ^8.0
- symfony/http-kernel: ^7.4 || ^8.0
- symfony/password-hasher: ^7.4 || ^8.0
- symfony/routing: ^7.4 || ^8.0
- symfony/security-bundle: ^7.4 || ^8.0
- symfony/validator: ^7.4 || ^8.0
- twig/twig: ^3.0
- uxf/core: 3.91.1
Requires (Dev)
None
Suggests
- ext-sodium: MFA: the default encryption of TOTP secrets (SodiumKms)
- symfony/key-management: MFA TOTP (uxf_security.mfa.totp): encryption of the secrets, needs Symfony 8.2
Provides
None
Conflicts
None
Replaces
None
- 3.x-dev
- 3.92.0
- 3.91.1
- 3.91.0
- 3.90.2
- 3.90.1
- 3.90.0
- 3.89.3
- 3.89.2
- 3.89.1
- 3.89.0
- 3.88.0
- 3.87.2
- 3.87.1
- 3.87.0
- 3.86.0
- 3.85.1
- 3.85.0
- 3.84.4
- 3.84.3
- 3.84.2
- 3.84.1
- 3.84.0
- 3.83.1
- 3.83.0
- 3.82.0
- 3.81.8
- 3.81.7
- 3.81.5
- 3.81.4
- 3.81.3
- 3.81.2
- 3.81.0
- 3.80.3
- 3.80.2
- 3.80.0
- 3.79.3
- 3.79.2
- 3.79.0
- 3.78.7
- 3.78.2
- 3.78.0
- 3.77.9
- 3.77.8
- 3.77.7
- 3.77.5
- 3.77.4
- 3.77.3
- 3.77.2
- 3.76.3
- 3.76.2
- 3.76.0
- 3.75.12
- 3.75.10
- 3.75.9
- 3.75.5
- 3.75.3
- 3.75.0
- 3.74.4
- 3.74.2
- 3.73.6
- 3.73.5
- 3.73.4
- 3.73.3
- 3.73.2
- 3.73.0
- 3.72.2
- 3.72.1
- 3.72.0
- 3.71.0
- 3.70.5
- 3.70.4
- 3.70.3
- 3.70.2
- 3.70.0
- 3.69.12
- 3.69.7
- 3.69.6
- 3.69.5
- 3.69.3
- 3.69.1
- 3.69.0
- 3.68.5
- 3.68.4
- 3.68.3
- 3.68.2
- 3.68.1
- 3.68.0
- 3.67.3
- 3.67.0
- 3.66.0
- 3.65.3
- 3.65.2
- 3.65.0
- 3.64.4
- 3.64.3
- 3.64.2
- 3.64.1
- 3.64.0
- 3.63.1
- 3.62.4
- 3.62.3
- 3.62.2
- 3.62.0
- 3.61.7
- 3.61.6
- 3.61.5
- 3.61.3
- 3.61.2
- 3.61.1
- 3.61.0
- 3.60.12
- 3.60.11
- 3.60.10
- 3.60.8
- 3.60.7
- 3.60.5
- 3.60.3
- 3.60.0
- 3.59.0
- 3.58.8
- 3.58.5
- 3.58.4
- 3.58.2
- 3.58.1
- 3.58.0
- 3.57.12
- 3.57.10
- 3.57.7
- 3.57.6
- 3.57.1
- 3.57.0
- 3.56.3
- 3.56.2
- 3.56.1
- 3.56.0
- 3.55.9
- 3.55.8
- 3.55.7
- 3.55.5
- 3.55.0
- 3.54.5
- 3.54.3
- 3.54.2
- 3.54.0
- 3.53.7
- 3.53.3
- 3.53.2
- 3.53.1
- 3.53.0
- 3.51.2
- 3.51.0
- 3.50.6
- 3.50.5
- 3.50.3
- 3.50.2
- 3.50.1
- 3.50.0
- 3.49.2
- 3.49.1
- 3.49.0
- 3.48.0
- 3.47.2
- 3.47.0
- 3.46.11
- 3.45.3
- 3.45.2
- 3.45.1
- 3.44.6
- 3.44.5
- 3.44.4
- 3.44.3
- 3.44.2
- 3.44.0
- 3.43.2
- 3.43.0
- 3.42.0
- 3.41.2
- 3.41.1
- 3.41.0
- 3.40.4
- 3.40.3
- 3.40.2
- 3.40.1
- 3.40.0
- 3.39.4
- 3.39.3
- 3.39.2
- 3.39.1
- 3.38.0
- 3.37.1
- 3.37.0
- 3.36.3
- 3.36.2
- 3.36.0
- 3.35.5
- 3.35.4
- 3.35.2
- 3.34.3
- 3.34.0
- 3.33.0
- 3.32.4
- 3.32.3
- 3.30.1
- 3.29.1
- 3.29.0
- 3.27.3
- 3.26.0
- 3.25.5
- 3.25.4
- 3.24.2
- 3.24.1
- 3.24.0
- 3.23.3
- 3.23.1
- 3.23.0
- 3.22.0
- 3.21.4
- 3.21.3
- 3.21.0
- 3.20.0
- 3.19.4
- 3.19.3
- 3.19.2
- 3.18.0
- 3.17.4
- 3.17.3
- 3.17.1
- 3.17.0
- 3.15.6
- 3.15.5
- 3.13.2
- 3.13.0
- 3.11.3
- 3.11.0
- 3.10.1
- 3.10.0
- 3.9.2
- 3.8.2
- 3.8.1
- 3.8.0
- 3.7.3
- 3.7.1
- 3.7.0
- 3.6.0
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- dev-main
This package is auto-updated.
Last update: 2026-11-29 15:56:57 UTC
README
JWT authentication for a Symfony API: password login, refresh tokens, cookie or header transport, role checks on controllers, OpenID Connect login (Google, Apple, …) and an optional OAuth 2.1 authorization server for MCP and other resource servers.
Documentation
- Users: the user provider and the user checker, both required
- Symfony security config: the firewall and the user provider of Symfony
- Authorization: roles on controllers
- Login, refresh, logout: endpoints, cookies, refresh tokens, login and logout events, the command line token, more token audiences
- Login attempts and rate limiting
- Multi-factor authentication (MFA): TOTP, passkeys (a login without a password too) and recovery codes
- OpenID Connect: login with Google, Apple and other identity providers
- OAuth 2.1: authorization server for MCP and other resource servers, personal tokens
Install
$ composer req uxf/security
// config/packages/uxf.php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('uxf_security', [
'user_class' => User::class, // required
'base_url' => 'https://uxf.cz', // required; no trailing slash, it is also the JWT/OAuth issuer
'public_key' => '%env(AUTH_PUBLIC_KEY)%', // required
'private_key' => '%env(AUTH_PRIVATE_KEY)%', // required
'user_checker' => ActiveUserChecker::class, // required (uxf/cms sets its ActiveUserChecker), see docs/users.md
// optional
'access_token_lifetime' => 'P10Y', // default 1 day
'refresh_token_lifetime' => 'P20Y', // default 1 month
'refresh_token_cookie_path' => '/api/auth', // default null = no refresh token cookie; /api/auth covers refresh and logout
'cookie_name' => 'Cookie-Name', // default Authorization - used for header + cookie
'cookie_secured' => false, // default true
'cookie_http_only' => false, // default true
'login_attempt' => [
'enabled' => true, // default true; false = no attempt recorded, no throttling
'limit' => 5, // default 5 failed logins per IP + username ...
'ip_limit' => 25, // default 25 failed logins per IP (0 = off) ...
'interval' => 900, // ... per 900 seconds
'methods' => [ // limits of other login methods, see docs/login-attempts.md
'api' => [], // the limit, ip_limit and interval of the password
'pin' => ['limit' => 0, 'ip_limit' => 0, 'username_limit' => 5],
],
],
// OpenID Connect - optional, see docs/oidc.md
'oidc' => [
'google' => [
'client_id' => 'xxx',
],
],
// OAuth 2.1 authorization server - optional, see docs/oauth.md
'oauth' => [
'enabled' => false,
],
// multi-factor authentication - optional, see docs/mfa.md
'mfa' => [
'enabled' => false,
],
]);
};
All lifetimes are ISO 8601 durations (DateInterval): PT1H, P1D, P30D, …
Values from env
Every option may come from env, with the processor of its type: %env(bool:MFA_REQUIRED)%,
%env(int:LOGIN_ATTEMPT_LIMIT)%. Except what the container needs when it is built:
user_classand the service IDsuser_checkerandmfa.totp.encryption.service;login_attempt.enabled,mfa.totp.enabled,mfa.passkey.enabledandmfa.totp.encryption.key_id, the checks of MFA read them;- the keys of a map: OIDC providers,
login_attempt.methods,mfa.totp.encryption.keys,oauth.clients; - a whole list or map from one variable (
json:), Symfony refuses it; each item may come from env.
A literal value is checked when the container is built, a value from env when it is used: a second factor without
a rate limit fails. bool: reads anything but true, 1, yes and on as false, a typo in MFA_REQUIRED turns
the enforcement off. A service reads its env variables when it is built, except the MFA encryption keys: they are
read with the first TOTP secret, an environment with MFA off needs none.
Keys
Tokens are signed with RS256. public_key and private_key are the PEM contents (not file paths), usually
from env variables:
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout -out public.pem
Every token carries iss: <base_url> and is rejected when it does not match, so changing base_url or
rotating the key pair invalidates every issued access token, including OAuth ones. The public key is
published as a JWK set on GET /api/auth/keys (kid is fixed), so another service can verify the tokens
without sharing the private key.
Database
The bundle has its own Doctrine entities in the uxf_security schema: RefreshToken, ExternalLogin
(OIDC accounts linked to a user), LoginAttempt, used with MFA TOTPCredential and RecoveryCode, and used with
OAuth (and MFA) OAuthRefreshToken and OAuthConsumedToken.
They reference the user through UserInterface, which the bundle maps to user_class via
resolve_target_entities. Generate a migration after installing or upgrading the bundle.