feat: track and revoke signed-in sessions #12

Merged
exler merged 3 commits from feature/session-revoke into main 2026-11-09 09:04:31 +01:00
Collaborator

Summary

  • Track signed-in devices and revoke sessions from Account and administrator user pages.
  • Revocation cancels associated authorization codes/access tokens and ends impersonation; session ownership and CSRF protections apply.
  • Record device/IP metadata with explicit trusted-proxy CIDRs. Fixed UTF-8 truncation of user agents and added CSRF regression coverage during review.

Review and upgrade caveats

Independent full-feature security review found no authorization, CSRF, impersonation or new-token issuance race defect. Both upgrade findings are addressed in documentation/UI: historical credentials cannot be associated with devices (allow 61 minutes after upgrade for their expiry), and rollback requires a verified pre-migration database backup plus the old image. Existing sessions survive migration. Revocation cannot end downstream application sessions or recall ID tokens.

Validation

  • go test -count=1 ./..., go vet ./..., go build ./cmd/thermopylae: pass locally.
  • Generated sqlc output verified; gofmt and diff checks clean.
  • Behavioral tests cover revocation, cross-user/admin authorization, CSRF, impersonation, tokens/codes, proxy spoofing, and escaped device metadata.
  • Local race execution is unavailable: ThreadSanitizer rejects this ARM64 host's VMA range. Existing PR CI must run go test -race ./....
  • Actual handler output from a disposable test fixture inspected in Chromium at desktop/mobile widths; this is fixture-rendered evidence, not production login.

Companion change

Homelab PR: exler/homelab#34. Merge/publish this application's image before deployment of the companion configuration. No production deployment performed.

Visual verification

Actual fixture-rendered Account and administrator routes, desktop 1280px / mobile 390px. Disposable local test database; no production login or session mutation.

account-desktop.png

account-mobile.png

admin-desktop.png

admin-mobile.png

## Summary - Track signed-in devices and revoke sessions from Account and administrator user pages. - Revocation cancels associated authorization codes/access tokens and ends impersonation; session ownership and CSRF protections apply. - Record device/IP metadata with explicit trusted-proxy CIDRs. Fixed UTF-8 truncation of user agents and added CSRF regression coverage during review. ## Review and upgrade caveats Independent full-feature security review found no authorization, CSRF, impersonation or new-token issuance race defect. Both upgrade findings are addressed in documentation/UI: historical credentials cannot be associated with devices (allow 61 minutes after upgrade for their expiry), and rollback requires a verified pre-migration database backup plus the old image. Existing sessions survive migration. Revocation cannot end downstream application sessions or recall ID tokens. ## Validation - `go test -count=1 ./...`, `go vet ./...`, `go build ./cmd/thermopylae`: pass locally. - Generated sqlc output verified; gofmt and diff checks clean. - Behavioral tests cover revocation, cross-user/admin authorization, CSRF, impersonation, tokens/codes, proxy spoofing, and escaped device metadata. - Local race execution is unavailable: ThreadSanitizer rejects this ARM64 host's VMA range. Existing PR CI must run `go test -race ./...`. - Actual handler output from a disposable test fixture inspected in Chromium at desktop/mobile widths; this is fixture-rendered evidence, not production login. ## Companion change Homelab PR: https://git.marut.network/exler/homelab/pulls/34. Merge/publish this application's image before deployment of the companion configuration. No production deployment performed. ## Visual verification Actual fixture-rendered Account and administrator routes, desktop 1280px / mobile 390px. Disposable local test database; no production login or session mutation. ![account-desktop.png](https://git.marut.network/attachments/5b497ff1-e902-4778-8cac-e9d01efb768e) ![account-mobile.png](https://git.marut.network/attachments/e09a52d3-4d5e-4c8b-87aa-87bf342e41ae) ![admin-desktop.png](https://git.marut.network/attachments/6e235ed9-8532-4e1c-b5db-aa006aa77441) ![admin-mobile.png](https://git.marut.network/attachments/a1027f98-bddf-4345-8d57-a19048fb78d9)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
docs(session): disclose tokens issued before session tracking stay valid until expiry
All checks were successful
Push Docker Image / test (pull_request) Successful in 1m12s
Push Docker Image / push (pull_request) Has been skipped
c0d140fa3c
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
exler merged commit 3e97dc3d84 into main 2026-11-09 09:04:31 +01:00
exler deleted branch feature/session-revoke 2026-11-09 09:04:31 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
exler/thermopylae!12
No description provided.