feat(vaadin-spring): add Vaadin-aware expired session handling - #25625
Open
totally-not-ai[bot] wants to merge 2 commits into
Open
feat(vaadin-spring): add Vaadin-aware expired session handling#25625totally-not-ai[bot] wants to merge 2 commits into
totally-not-ai[bot] wants to merge 2 commits into
Conversation
Port UidlExpiredSessionStrategy from SSO Kit so that a session expired by Spring Security concurrency control ends in a client-side reload instead of a redirect the Vaadin client cannot follow: for framework internal requests it writes a Vaadin-Refresh token into the response body, other requests are redirected. Unlike the SSO Kit original, the destination URL is context-relative and the redirect goes through a RedirectStrategy, so an application deployed under a context path gets /app/ instead of //app.
VaadinSecurityConfigurer now installs UidlExpiredSessionStrategy on the session management configuration, so an application that turns on Spring Security concurrency control gets Vaadin-aware session expiration without extra wiring. Spring Security only creates the ConcurrentSessionFilter when a maximum number of sessions is set, so this is a no-op otherwise. Session management is only customized when the application has it configured, which Spring Boot does by default, and can be turned off with enableSessionManagementConfiguration(false). A custom strategy can be set with expiredSessionStrategy(SessionInformationExpiredStrategy).
Contributor
Author
Type of change
How to test
API changescom.vaadin.flow.spring.security.UidlExpiredSessionStrategy// Added
public class UidlExpiredSessionStrategy implements SessionInformationExpiredStrategy
public UidlExpiredSessionStrategy() // sends the browser to the context root
public UidlExpiredSessionStrategy(String destinationUrl) // context-relative URL
public void setRedirectStrategy(RedirectStrategy redirectStrategy) // used for non-UIDL requests
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOExceptioncom.vaadin.flow.spring.security.VaadinSecurityConfigurer// Added
public VaadinSecurityConfigurer enableSessionManagementConfiguration(boolean enableSessionManagementConfiguration)
public VaadinSecurityConfigurer expiredSessionStrategy(SessionInformationExpiredStrategy expiredSessionStrategy)Test coverage
Follow-ups
|
|
Contributor
totally-not-ai Bot
added a commit
to vaadin/docs
that referenced
this pull request
Sep 10, 2026
…ions vaadin/flow#25625 adds UidlExpiredSessionStrategy and makes VaadinSecurityConfigurer install it by default, and vaadin/flow#25627 adds KeycloakOidcUserMapper behind a keycloakRoleMapping() opt-in. Both were ported from SSO Kit, so two of the migration gaps close. Moves the two features out of the gaps section and into the migration steps that need them, with a since badge for the version they arrive in and the previous manual approach kept in a note for earlier versions. Updates the feature mapping table and the checklist to match.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



new feature · vaadin-spring · apps that limit concurrent sessions
Background — session concurrency control. Spring Security can limit how
many sessions one user has at the same time. When the limit is passed, the
oldest session is marked as expired, and the next request from that browser
is answered by the configured expired-session strategy.
A Vaadin application that turns this on got a plain redirect, which the
Vaadin client cannot follow, so the browser stayed on a dead page until the
user reloaded by hand. The client now gets the token it understands and
reloads on its own. Applications that do not limit concurrent sessions are
not affected.
Risks:
VaadinSecurityConfigurer;no existing signature changed
strategy instead of the Spring Security redirect one, which is what such an
app wants;
enableSessionManagementConfiguration(false)keeps the oldbehavior
Security has already expired the session and logged the user out
cost when concurrency control is off
Context. SSO Kit has carried
UidlExpiredSessionStrategysince 1.0because every Vaadin app with concurrency control needs it, and Flow already
has its sibling
UidlRedirectStrategy. Keeping the two together lets SSO Kitdelegate instead of shipping its own copy.
UidlExpiredSessionStrategy, ported from SSO Kit: it writesVaadin-Refresh: <url>into the body of a framework internal request andredirects any other request.
RedirectStrategy, so an app under a context path gets/app/where theSSO Kit original produced
//app.VaadinSecurityConfigurerinstall the strategy by default. It onlytouches session management when the application has it configured, which
Spring Boot does, so a hand-built filter chain without session management
is left alone.
enableSessionManagementConfiguration(boolean)to turn that off, andexpiredSessionStrategy(SessionInformationExpiredStrategy)to set a customstrategy.
excluded the new class from
SpringClassesSerializableTestthe same wayUidlRedirectStrategyis.