Skip to content

feat(maintenance): add REST endpoints for session management (#35206)#35733

Merged
hassandotcms merged 4 commits into
mainfrom
35193-feature-session-management-apis
May 18, 2026
Merged

feat(maintenance): add REST endpoints for session management (#35206)#35733
hassandotcms merged 4 commits into
mainfrom
35193-feature-session-management-apis

Conversation

@hassandotcms
Copy link
Copy Markdown
Member

@hassandotcms hassandotcms commented May 18, 2026

Migrates the Logged Users tab off the legacy UserSessionAjax DWR class by adding three REST endpoints on MaintenanceResource:

  • GET /api/v1/maintenance/_sessions list active sessions
  • DELETE /api/v1/maintenance/_sessions/{token} invalidate one session
  • DELETE /api/v1/maintenance/_sessions invalidate all but caller

Covered by 7 unit tests (SessionTokenUtilTest) and 11 integration tests (MaintenanceResourceIntegrationTest) including byte-for-byte parity with the legacy implementation, CSRF expiry, self-kill rejection, and unknown-token 404 paths.

This PR fixes: #35193

This PR fixes: #35193

Migrates the Logged Users tab off the legacy UserSessionAjax DWR class
by adding three REST endpoints on MaintenanceResource:

- GET    /api/v1/maintenance/_sessions           list active sessions
- DELETE /api/v1/maintenance/_sessions/{token}   invalidate one session
- DELETE /api/v1/maintenance/_sessions           invalidate all but caller

The HMAC obfuscation and 15-minute CSRF expiry from the legacy class are
preserved so raw HTTP session ids never leave the JVM. HMAC helpers are
extracted into a shared SessionTokenUtil; UserSessionAjax keeps the
static obfuscate/validate methods as @deprecated shims that delegate to
the utility, so existing DWR call sites remain unchanged.

Constant-time MessageDigest.isEqual replaces String.equals on token
comparison; explicit UTF-8 byte encoding replaces the platform default.

Covered by 7 unit tests (SessionTokenUtilTest) and 11 integration tests
(MaintenanceResourceIntegrationTest) including byte-for-byte parity with
the legacy implementation, CSRF expiry, self-kill rejection, and
unknown-token 404 paths.
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 18, 2026

Claude encountered an error after 0s —— View job


Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@github-actions github-actions Bot added the Area : Backend PR changes Java/Maven backend code label May 18, 2026
…in /_sessions

Address review feedback on #35733: the previous code only surfaced
"Unable to resolve anonymous user", which was confusing for admins
calling /_sessions with a perfectly valid user. The real root cause —
the primary PortalUtil.getUser lookup returning null or throwing —
was hidden.

- Log a warning the moment the primary lookup fails so operators can
  see the underlying issue even when the anonymous fallback succeeds.
- If the anonymous fallback also fails, the thrown DotRuntimeException
  now names both failures in order, so the 500 response actually
  describes what went wrong.
@hassandotcms hassandotcms marked this pull request as ready for review May 18, 2026 17:53
@hassandotcms hassandotcms added this pull request to the merge queue May 18, 2026
@hassandotcms hassandotcms removed this pull request from the merge queue due to a manual request May 18, 2026
@hassandotcms hassandotcms enabled auto-merge May 18, 2026 21:25
@hassandotcms hassandotcms added this pull request to the merge queue May 18, 2026
Merged via the queue into main with commit d48b8da May 18, 2026
49 of 51 checks passed
@hassandotcms hassandotcms deleted the 35193-feature-session-management-apis branch May 18, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area : Backend PR changes Java/Maven backend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[FEATURE] Session Management APIs

2 participants