If you have ever wired a Symfony app to Keycloak, Entra ID or Authentik, you know the drill: pull in a third-party bundle or write your own authenticator and hope you got the token checks right. Symfony 8.2, released as a stable version on Saturday, November 28, makes that unnecessary. The full OpenID Connect login now ships with the framework, alongside a sudo mode that asks for the password again before sensitive actions such as deleting an account, even if the session started hours ago. Both replace code that many teams have been maintaining themselves, often with gaps.
We went through both features in the 8.2.0 source, checked the defaults and noted what to watch for when you upgrade. Developers who want the rest of the Symfony features will find them in the official blog, where the open-source project lists every entry in the Symfony releases calendar and explains the release process.
What Symfony 8.2 changes for login and access control
Symfony 8.2 is a minor release of the PHP framework with a very long changelog. The Security component alone picked up dozens of features, from OIDC login and DPoP-bound tokens to wildcards in the role hierarchy. Three of them are useful to almost any web app right away: the new oidc_login authenticator, the IS_AUTHENTICATED_RECENTLY and IS_AUTHENTICATED_VERY_RECENTLY attributes, and an option that logs out a blocked user on their next request.
The basics first. Symfony 8.2 requires PHP 8.4 or later and is maintained until July 2027. If you prefer a longer runway, Symfony 7.4 is the current LTS, with bug fixes until November 2028 and security fixes until November 2029. Our rundown of PHP 8.6 and its security fixes covers the runtime side.
OpenID Connect login without an extra bundle
OpenID Connect (OIDC) is the protocol behind most “Log in with …” buttons. Your app sends the browser to an identity provider, the user signs in there and comes back with a code, which the app exchanges for tokens. Since 6.3, Symfony could validate such tokens, but only for APIs that already receive them. The browser login itself, the Authorization Code Flow, arrives with 8.2.
Setup is short. Add two packages:
composer require symfony/http-client web-token/jwt-library
Then add the authenticator to your firewall:
# config/packages/security.yaml
security:
providers:
oidc_users:
oidc: ~
firewalls:
main:
provider: oidc_users
oidc_login:
provider_uri: '%env(OIDC_PROVIDER_URI)%'
client_id: '%env(OIDC_CLIENT_ID)%'
client_authentication:
client_secret_basic: '%env(OIDC_CLIENT_SECRET)%'
scope: ['openid', 'profile', 'email']
You don’t configure the provider’s endpoints. Symfony reads them from its .well-known/openid-configuration document and, by default, caches them for an hour. After signing in, users land on /oidc/callback; the flow starts at /oidc/start. If your login page offers several options, link to the _oidc_login_start_main route in Twig, where main is the firewall name.
The more interesting part is what you no longer have to write. The authenticator checks state and nonce against login CSRF, enables PKCE with S256 so an intercepted code is useless, and verifies the ID token signature against the provider’s published keys. It validates the iss, aud, exp and iat claims plus the iss parameter of the response to block mix-up attacks, requires HTTPS for every endpoint (loopback hosts excepted during development) and never follows HTTP redirects. Those are exactly the checks that homegrown OIDC integrations tend to get wrong in code review.
Two defaults are worth knowing. Clock skew tolerance is zero seconds (allowed_time_drift: 0). If your server and the provider disagree by even a few seconds, logins can fail the ID token’s time checks, so fix NTP or raise the value slightly. And unless you say otherwise, signature verification only accepts RS256. Providers that sign ID tokens with ES256 need an entry under id_token_signature.algorithms.
The built-in oidc provider only builds in-memory users from the claims. To keep accounts in your database or map provider groups to roles, write your own provider. Its loadUserByIdentifier() method receives every claim as the second argument:
public function loadUserByIdentifier(string $identifier, array $attributes = []): UserInterface
{
// $identifier is the "sub" claim by default
$user = $this->users->findOneBy(['oidcSubject' => $identifier]) ?? new User($identifier);
$user->setEmail($attributes['email'] ?? null);
$user->setRoles(\in_array('admins', $attributes['groups'] ?? [], true) ? ['ROLE_ADMIN'] : []);
return $user;
}
For logout, set enable_end_session: true. Without it, Symfony only ends its own session. The user stays signed in at the provider and gets straight back in on the next visit to a protected page, which is not what anyone expects on a shared machine. Access tokens can be renewed automatically with refresh_access_token if you request offline_access in the scope. One limitation, confirmed by the maintainers in the comments: oidc_login deliberately adds no remember-me badge. How long a login lasts is the provider’s call.
Sudo mode: fresh credentials for sensitive actions
Until now the strongest check, IS_AUTHENTICATED_FULLY, told you how a session started but not when. Someone who logged in with a password in the morning and left the laptop open is still fully authenticated in the afternoon. Symfony 8.2 adds two attributes. IS_AUTHENTICATED_RECENTLY requires a login within the last two hours, IS_AUTHENTICATED_VERY_RECENTLY one within the last five minutes:
#[IsGranted('IS_AUTHENTICATED_RECENTLY')]
public function changeEmail(): Response { /* ... */ }
#[IsGranted('IS_AUTHENTICATED_VERY_RECENTLY')]
public function deleteAccount(): Response { /* ... */ }
You set both windows globally in seconds, for example recent_authentication_lifetime: 3600 and very_recent_authentication_lifetime: 60. The attributes work wherever the other IS_AUTHENTICATED_* attributes do: in access_control, in Twig and in security expressions.
When the check fails, Symfony doesn’t return a 403. It asks for credentials again. With form_login this works out of the box, with the username already filled in. There is a catch: many login controllers redirect users who are already logged in, which would send the re-authentication in circles. The new getReAuthenticationAttribute() method on AuthenticationUtils tells the two cases apart. It returns the denied attribute or null, and your controller should only redirect on null. With OIDC login, Symfony sends the user back to the provider with prompt=login and reads the auth_time claim, so a silent sign-in through an old provider session doesn’t count as fresh.
Reading the code turns up two details the announcement only touches on. Users logged in through a remember-me cookie never pass the new checks. And the timestamp comes from authentication proofs that tokens store as of 8.2. Sessions that started before the upgrade don’t carry those proofs yet, so they fail the check. Expect users to re-enter their password once before protected actions after you deploy. Custom token classes that don’t implement getAuthenticationProofs() never pass either and trigger a deprecation notice.
If you need stricter rules, extend AuthenticationTrustResolver. Tokens now record which authentication methods were used and when, using the RFC 8176 names such as pwd for a password or hwk for a hardware key. A banking app could decide that “very recently” only counts if a hardware key was used during the session.
Logging out blocked accounts right away
The third piece is easy to overlook but closes an old gap. A user checker that rejects locked or expired accounts used to run only at login. If an admin disabled an account, its owner could keep working until the session expired. With user_checker_on_refresh: true on the firewall, the checker runs whenever Symfony reloads the user from the session. If it throws, the user is logged out on that same request.
The option is off by default because the checker now runs on every request. Keep it fast and free of side effects: no emails, no database writes. On stateless API firewalls Symfony refuses to compile the container with an error, since those never reload a user from a session. To add your own logout reasons, listen to the new CheckRefreshedUserEvent.
What else is new in 8.2.0: testing, Mailer, Messenger, Misc changes
Beyond login, version 8.2.0 brings a long list of useful improvements that the Symfony team covers one by one in its “New in Symfony 8.2” series. The posts on Serializer improvements, Doctrine improvements, RateLimiter improvements and Testing improvements are the ones most teams will open first, alongside several parts under the heading Misc changes. The Serializer component, for example, keeps getting better at JSON, Doctrine gains a few entity and mapping helpers, and DependencyInjection as well as ExpressionLanguage pick up smaller quality-of-life changes. Symfony UX shows up where Twig needs to pass normalized data into a component rather than a JSON string nested inside JSON.
Two items fit the login theme closely. Login throttling now dispatches a RateLimitExceededEvent when one of the rate limiters kicks in, which you can hook into for logging or alerts. And the Mailer component can sign and encrypt emails with PGP/MIME. This is a big release for emails in general: you can set an SMTP timeout option in the DSN instead of relying on PHP’s 60-second default, webhook receivers can verify Standard Webhooks Signatures, and several new Mailer and Notifier bridges land for existing email APIs. Notifications go through the same family of transports. If you send mail asynchronously, Messenger workers retry after a timeout without stalling the other transports.
The testing improvements are easy to miss and worth having. After you follow a redirect, an application test still sees the emails and Messenger messages from the previous request, and one mocked clock can be shared by all of your code. When framework.test is enabled, Symfony lowers password hashing costs and turns off the leaked-password check, which should make test suites with lots of logins much quicker. Elsewhere, HttpClient gets clearer retries and a fallback, the Console component helps with invokable command arguments, and Misc changes include helpers for time-ordered UUIDs and ULIDs plus a few tag and alias clean-ups. Headers and cache behaviour stay familiar in day-to-day work, but they are documented in the same series.
Upgrading to Symfony 8.2: what to check first
The upgrade itself is the usual minor bump:
composer config extra.symfony.require "8.2.*"
composer update "symfony/*"
The upgrade file lists eight entries marked “BC BREAK”, meaning small backward compatibility breaks. Two matter for authentication and authorization. A failing #[IsCsrfTokenValid] now throws an InvalidCsrfTokenException from the Security\Http namespace with a 403 status instead of the old one from Security\Core, so code catching the old class will miss it. And an access_control rule with several entries under roles is deprecated in favor of allow_if or the role hierarchy. If you use the OIDC token handler for APIs, set enforce_at_jwt_type explicitly now; it will default to true in Symfony 9.0.
Before upgrading, also check your current patch level. November brought fixes for the Symfony Serializer (CVE-2026-118515) and for HttpFoundation. Make sure you already have them, so the security update and the feature upgrade stay separate.
Our take
For new projects with single sign-on, Symfony 8.2 is a good reason to drop external OIDC bundles. The checks the authenticator performs by default cover the mistakes we see most often in homegrown versions. Sudo mode costs an existing form_login app a few lines and a tweak to the login controller. We would turn it on immediately for account settings, payments and admin areas.
If you need LTS, stay on 7.4 and wait for Symfony 8.4 in November 2027. Everyone else can start now, on a branch first, with the 8.2.0 release announcement, UPGRADE-8.2.md in the repository and the Symfony team’s posts on OpenID Connect login and sudo mode at hand.




