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
Ports upstream PR #5169 (author: Jan-Robin Aumann) to modern Stratos
patterns on feature/Angular-21.
Backend (clean port):
- api/structs.go — JSON tags on TokenRecord so it can be serialised
- session.go — new AuthTokenEnvelope struct and retrieveToken handler.
The handler reads user_id from the signed session cookie, verifies
the session, then returns the UAA TokenRecord for that user only.
No client-supplied user identifier anywhere — users can only ever
retrieve their own token.
- main.go — GET /api/v1/auth/token route
Frontend (rewritten for Angular 21 patterns):
- store/types/auth.types.ts — TokenData + AuthTokenEnvelope interfaces
- store/public-api.ts — exported via `export type`
- page-header.component.ts — uses inject(HttpClient) + inject(SnackBarService),
firstValueFrom(), and navigator.clipboard.writeText(). No ngx-clipboard
dependency.
- page-header.component.html — new vpn_key button + dropdown in the
Tailwind toggle pattern (isTokenMenuOpen), @if control flow, no mat-*
Security hardening over the upstream PR: the original kept each token in
a hidden <div>{{ token$ | async }}</div> buffer for the clipboard-copy
library to read, which left the raw tokens live in the DOM where browser
extensions could scrape them. This port skips the DOM buffer entirely —
the token is fetched on-demand when the user clicks Copy and written
straight to the clipboard API.
The /auth/token envelope is also re-fetched every time the menu opens
(via shareReplay(1) in a per-open observable) so users can't receive a
stale or expired token from a process-lifetime cache.
Co-authored-by: Jan-Robin Aumann <jaumann@anynines.com>
0 commit comments