ReviewOS

also looking at this

loghqorg/loghq

Deploy: uniform auth session model (main → production)

#7
Merged glennmichael123 wants to merge main into production
282 files +3028 -64856
config/auth.tsmodified+27-10
Changes to config/auth.ts
@@ -47,20 +47,37 @@ export default {
4747 password: env.AUTH_PASSWORD_FIELD || 'password',
4848
4949 /**
50 * Access-token expiry in milliseconds (default: 1 hour).
50 * Access-token expiry in milliseconds (default: 7 days).
5151 *
52 * Access tokens are deliberately short-lived: a leaked bearer (logs,
53 * proxy, browser storage) is then usable for an hour, not a month. The
54 * paired refresh token (`refreshTokenExpiry`) carries the long-lived
55 * session and is rotated on use, so UX is unaffected.
52 * This value IS the browser session length, not just an API-bearer TTL.
53 * The custom auth actions (LoginAction, RegisterAction,
54 * VerifyTwoFactorLoginAction, SocialCallbackAction) mirror the issued
55 * access token into the HttpOnly `auth-token` cookie (see
56 * Actions/Auth/authCookie.ts) because the dashboard is server-rendered stx
57 * with no client hydration and has no other way to know who is asking. Both
58 * the cookie's Max-Age and the `oauth_access_tokens.expires_at` row are
59 * stamped from here, and nothing extends either one — `getUserFromToken`
60 * bumps `updated_at` on every request but leaves `expires_at` alone, then
61 * deletes the row once it passes. So a signed-in operator is logged out
62 * exactly this long after login regardless of activity.
63 *
64 * This is the BASELINE only. LoginAction and VerifyTwoFactorLoginAction
65 * pass a per-login `expiresInMinutes` from the sign-in form's "remember me"
66 * checkbox (see sessionExpiryMinutes in Actions/Auth/authCookie.ts): a week
67 * unchecked, 30 days checked. This default covers the entry points that have
68 * no such checkbox — register, SSO — so they land on the baseline week.
5669 */
57 // 30 days: the dashboard is a long-lived session (token kept in localStorage +
58 // a cookie). A 1h expiry logged users out mid-session.
59 tokenExpiry: env.AUTH_TOKEN_EXPIRY || 30 * 24 * 60 * 60 * 1000,
70 tokenExpiry: env.AUTH_TOKEN_EXPIRY || 7 * 24 * 60 * 60 * 1000,
6071
6172 /**
62 * Refresh-token expiry in milliseconds (default: 30 days). This is the
63 * long-lived credential exchanged for fresh access tokens.
73 * Refresh-token expiry in milliseconds (default: 30 days).
74 *
75 * NOT WIRED UP. A refresh token is minted and returned in the login
76 * response body by the auth actions and consumed by nothing: there is no
77 * refresh route and no cookie stores it, so the value below only bounds a
78 * row in `oauth_refresh_tokens` that never gets read. Session length is
79 * `tokenExpiry` above, alone — the long-lived `auth-token` cookie IS the
80 * session.
6481 */
6582 refreshTokenExpiry: env.AUTH_REFRESH_TOKEN_EXPIRY || 30 * 24 * 60 * 60 * 1000,
6683