Implements the GET /pass?token=... endpoint for validating session tokens, resolving the correct target application domain dynamically, and routing users seamlessly using ephemeral 1-click magic links. Also updates the Sessions Hub UI hand-off modal to display the 1-Click Magic Link and adds full test coverage. Co-authored-by: mrteye <1945243+mrteye@users.noreply.github.com>
1.6 KiB
1.6 KiB
TASK METADATA
- Target Files:
server/main.tsui/components/SessionsPage.tsxserver/main.test.ts
- Core Objective: Implement
GET /pass?token=...for 1-click ephemeral session redemption and update the Sessions Hub hand-off UI with copyable magic links. - Dependencies:
server/auth-session.ts,server/db.ts - Additional Important Notes: Sets wildcard
.atyg.orgcookie, cleans host-only cookie, and redirects cleanly to target app domain or dashboard.
1. Architectural Considerations & Risks
- Security & Cookie Scoping:
/passmust validate that the token is active and not expired before issuing Set-Cookie headers.- Must use
getCookieDomain()so subdomains (e.g.ed-droid.atyg.org) receive the session cookie immediately.
- Target URL Redirection:
- If the session has custom scopes for an application (e.g.
app:ed-droid),/passlooks up the domain ofed-droidand redirects directly tohttps://ed-droid.atyg.org. - If no specific app is scoped, redirects to
/dashboard.
- If the session has custom scopes for an application (e.g.
2. Proposed Implementation
- Backend Route (
server/main.ts):- Add
GET /pass:- Reads
c.req.query("token"). - Validates token against Valkey/PostgreSQL.
- Sets
session_idcookie on.atyg.org. - Determines redirect URL and returns
302 Found.
- Reads
- Add
- UI Update (
ui/components/SessionsPage.tsx):- Add "1-Click Magic Link" tab in
#handoffModal. - Copyable link:
https://auth.atyg.org/pass?token=ay_sess_....
- Add "1-Click Magic Link" tab in
- Automated Tests (
server/main.test.ts):- Add test case verifying token validation, cookie setting, and redirection.