Repository navigation
Conversation
…fresh A new localConfig.json option, loginPersistence, set to browserSession ties the login to the browser session. A session cookie marks the browser session at login; a persisted login without it, left by an earlier browser session or made before the option was turned on, is not restored, and its session is ended on the server with its own access token. When a token refresh fails, MapStore now also sends the logout to the server with the token it held, instead of clearing only the client state.
1 task done
A new action, SESSION_ENDED, carries the reason when MapStore ends a login without a user action: browserSession when a stored login of an earlier browser session is not restored, refreshFailed when the token refresh fails. The first is dispatched on the first location change, once the application has started. The Logout button does not dispatch it.
This branch has not been deployed
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.
Description
A login with OpenID Connect survives a browser restart, because the security state, access token included, is kept in
localStorage. The next token refresh then renews the session for as long as the session at the identity provider is valid. And when a token refresh fails, MapStore only clears its own state:DELETE /session/logoutis sent only by the Logout button, so the session on the server and at the identity provider stays alive.localConfig.jsonoptionloginPersistence:local(the default, as today) orbrowserSession. WithbrowserSession, a session cookie (ms2-login-session, on the path of the application) marks the browser session at login and is removed at logout. A persisted login without it is not restored: MapStore starts logged out and sendsDELETE /session/logoutwith the stored access token. This covers a login left by an earlier browser session and one made before the option was turned on. The login is still shared by the tabs of the browser and survives page reloads.DELETE /session/logoutwith the token it held.SESSION_ENDED, withreasonset tobrowserSessionorrefreshFailed(SESSION_END_REASONS), so that a project can react to it, for example with a notice. The first is dispatched on the first location change, once the application has started; the Logout button does not dispatch it.With
globalLogoutEnabled, GeoStore then also ends the session at the identity provider. When the stored access token has already expired, that needs geosolutions-it/geostore#611 and geosolutions-it/geostore#613 (GeoStore 2.7.1); older versions just answer the logout without effect at the provider.Please check if the PR fulfills these requirements
Issue
What is the current behavior?
#13166
After a browser restart MapStore still shows the user as logged in and the next refresh renews the session. After a failed refresh the session on the server and at the identity provider stays alive.
What is the new behavior?
With
loginPersistence: "browserSession", a browser restart ends the login, in MapStore and on the server. With any setting, a failed refresh ends the session on the server too. In both cases MapStore dispatchesSESSION_ENDEDwith the reason.Other useful information
Unit tests:
LoginPersistenceUtils-test, new cases inStandardStore-test(restored with the marker and by default, dropped and logged out on the server without it),security-test(a failed refresh dispatchesLOGOUTandSESSION_ENDEDand sends the logout with the old token, a successful one does not) andlogin-test(the marker is set at login and removed at logout only withbrowserSession;SESSION_ENDEDis dispatched once after a login was dropped at startup). The whole suite passes locally.I also tested it in Chromium with Playwright, against Keycloak 26.0.7 (access tokens of 60 seconds) and a GeoStore build with #611 and #613,
globalLogoutEnabled=true. The number of sessions of the user in Keycloak was read through its admin API after each step. A browser restart was simulated by dropping the session cookies and keepinglocalStorageand the persistent cookies. The actions were recorded in debug mode (?debug=true) through a stand-in for the Redux devtools hook.browserSession, page reloadbrowserSession, restart after the access token expiredDELETE /session/logoutwith the stored token (204), Keycloak sessions 1 → 0browserSession, restart with the token still validbrowserSession, restartSESSION_ENDEDwithbrowserSessionand noLOGOUTat startupbrowserSession, Logout buttonDELETE /session/logout(204), marker removed, Keycloak sessions 1 → 0;LOGOUTonly, noSESSION_ENDEDbrowserSessionturned onDELETE /session/logout(204), Keycloak sessions 1 → 0,LOGOUTthenSESSION_ENDEDwithrefreshFailed; without this change the same case left the Keycloak session alive (1)Browsers set to restore the previous session at startup also restore session cookies, so with them the login is kept; the documentation says so.