Honor Admin Session Timeout for the admin console REST token#26092
Honor Admin Session Timeout for the admin console REST token#26092renatsaf wants to merge 2 commits into
Conversation
The admin console authenticates its backend REST calls with a session
token whose lifetime was taken solely from the rest-config
session-token-timeout (default 30 minutes), ignoring the user-facing
"Admin Session Timeout" (das-config adminSessionTimeoutInMinutes).
As a result, setting Admin Session Timeout to 0 ("never") still logged
the user out after 30 minutes: the HTTP session never expired, but the
REST token did, and the next REST call returned 401 and forced a
re-login. The defaults were also inconsistent (GUI 60 min vs token
30 min).
- RestSessionManager: a non-positive timeout now means the session
never expires (previously 0 expired immediately).
- AdminConsoleAuthModule: pass the configured adminSessionTimeoutInMinutes
when creating the REST session so the token lifetime matches the GUI
session.
- SessionsResource: honor the timeout supplied by the (already
admin-authenticated) login request, falling back to the existing
session-token-timeout default for other REST clients.
Fixes eclipse-ee4j#24982
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
The solution probably works but I have security concerns. The Admin GUI web app is a client to the HTTP admin backend and the current solution is that the web app retrieves the session timeout from the configuration and passes it to the backend as a parameter.
Sending the timeout for a token by a client is not a good security practice. it could be potentially exploited, even though SessionsResource is only accessible by an authenticated user.
Is it possible to read the session timeout directly in the SessionsResource class on the backend, instead of passing it from the Admin web app?
Something like:
- Remove sessionTimeoutInMinutes from the payload in AdminConsoleAuthModule
- Read adminSessionTimeoutInMinutes directly in SessionsResource (via injected Domain or DasConfig)
- Decide explicitly whether adminSessionTimeoutInMinutes should apply - it should apply only to console-originated ones, when
NetUtils.isLocal(grizzlyRequest.getRemoteAddr()) && grizzlyRequest.getHeader("X-GlassFish-Remote-Host") != null. The request must be from the local host (Admin GUI is always on the same host) and it must have the header, which is only sent by the Admin GUi, not by other clients like asadmin or REST clients.
Addresses review feedback: the previous approach had the admin console read adminSessionTimeoutInMinutes and pass it to SessionsResource as a request parameter. Letting a client dictate its own token lifetime is a weak security practice, even for an authenticated caller. SessionsResource now reads adminSessionTimeoutInMinutes directly from DasConfig and only applies it to console-originated requests, detected the same way GenericAdminAuthenticator does: the request must come from the local host and carry the X-GlassFish-Remote-Host header (only the co-located admin console sends it). Other REST clients (asadmin, scripts) keep the rest-config session-token-timeout default and can no longer influence their token lifetime. AdminConsoleAuthModule is reverted to no longer send the timeout. The RestSessionManager non-positive-timeout-means-never change is unchanged. Fixes eclipse-ee4j#24982 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks @OndroMih, good catch — agreed that letting the client set its own token lifetime is the wrong place for it. I've reworked it along the lines you suggested:
A config-read failure is logged at FINE and falls back to the rest-config default, so it can't break login. PTAL. |
Problem
Setting Admin Session Timeout to
0("never") in the admin console still logs the user out after ~30 minutes of inactivity (issue #24982).Root cause
The console relies on two independent timers:
das-config/adminSessionTimeoutInMinutesviaGuiUtil.initSessionAttributes()(0→setMaxInactiveInterval(-1), never expires).SessionsResourcewith a lifetime taken solely fromrest-config/session-token-timeout(default 30 min) — it never consulted the Admin Session Timeout setting.So with Admin Session Timeout = 0, the HTTP session never expired, but the REST token still lapsed after 30 minutes. The next click made a REST call that returned 401, which
RestUtilhandles by invalidating the session and redirecting to login. The defaults were inconsistent too (GUI 60 min vs token 30 min), so the documented GUI timeout was effectively overridden by the token.Fix
RestSessionManager: a non-positive timeout now means "never expire" (previously0made the session inactive immediately).AdminConsoleAuthModule: passes the configuredadminSessionTimeoutInMinuteswhen creating the REST session, so the token lifetime matches the GUI session.SessionsResource: honors the timeout supplied by the (already admin-authenticated) login request, falling back to the existingsession-token-timeoutdefault for other REST clients — so direct REST API callers are unaffected.Testing
common-util,rest-service,admingui/common).Fixes #24982
🤖 Generated with Claude Code