You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Property expiredUrl of SessionManagement is not handled correctly
Actual Behavior
This situation is verified by having the limit of max 1 sessions for user in security config. Then signing in with the first user (A) and then logging in with the second user (B), the first one (A) is being invalidated on the server side correctly. When the first user (A) refreshes the page, instead of too many sessions per user error message, Spring security returns Invalid Session error code.
Detailed procedure is described below:
For cocurrent session, in this case expiredUrl not work, this is my use case:
Open the first tab/browser and sign in
Open the second tab/browser and sign in
Go to the first tab/browser and refresh the page(F5) and redirect to invalidSessionUrl. KO
On step #3 spring will return invalidSessionUrl error message instead of too many sessions per user.
In order to avoid the session being shared, I reccomend to use two different browsers or a browser in incognito mode.
Note: The third step must be performed before the session timeout otherwise the session will be invalidated by timeout instead of concurrent session.
For testing, in demo project the session expiration is configured to 20 seconds.
Expected Behavior
Open first browser = go to login page, insert credential and go home page.
Open second browser = go to login page, insert credential and go home page.
Go to first browser and press refresh page(F5) and redirect to expiredUrl. (Redirect to invalidSessionUrl only if session expired)
Custom filter is almost identical to the ConcurrentSessionFilter, except in doFilter(...) before sending the redirect, creating new empty session.
By doing this, when the SessionManagementFilter is invoked, it does not handle InvalidSession error.
Spring Boot Security
Property
expiredUrl
of SessionManagement is not handled correctlyActual Behavior
This situation is verified by having the limit of max 1 sessions for user in security config. Then signing in with the first user (A) and then logging in with the second user (B), the first one (A) is being invalidated on the server side correctly. When the first user (A) refreshes the page, instead of
too many sessions per user
error message, Spring security returnsInvalid Session
error code.Detailed procedure is described below:
For cocurrent session, in this case expiredUrl not work, this is my use case:
On step #3 spring will return
invalidSessionUrl
error message instead oftoo many sessions per user
.Note: The third step must be performed before the session timeout otherwise the session will be invalidated by timeout instead of concurrent session.
For testing, in demo project the session expiration is configured to 20 seconds.
Expected Behavior
Configuration
WorkAround
Add custom filter
customConcurrentSessionFilter
before ConcurrentSessionFilter.Remove expiredUrl from default configuration because it is already declared into the custom filter
Custom filter is almost identical to the ConcurrentSessionFilter, except in
doFilter(...)
before sending the redirect, creating new empty session.By doing this, when the
SessionManagementFilter
is invoked, it does not handleInvalidSession
error.Version
Spring boot 1.4.2.RELEASE
Sample
https://github.com/MassimoScattarella/FixConcurrentSessionForSpringBootSecurity
The text was updated successfully, but these errors were encountered: