ReviewOS

also looking at this

loghqorg/loghq

Deploy: GitHub sign-in credentials, auth helper move, callback defaults

#9
Merged glennmichael123 wants to merge main into production
10 files +15 -12

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

app/Actions/Auth/LoginAction.tsmodified+1-1
Changes to app/Actions/Auth/LoginAction.ts
@@ -4,7 +4,7 @@ import { Auth, createTwoFactorChallenge, getTwoFactorState } from '@stacksjs/aut
44import { User } from '@stacksjs/orm'
55import { response } from '@stacksjs/router'
66import { schema } from '@stacksjs/validation'
7import { buildAuthCookie, sessionExpiryMinutes } from './authCookie'
7import { buildAuthCookie, sessionExpiryMinutes } from '../../Support/authCookie'
88
99/**
1010 * Email/password sign-in, registered at POST /api/auth/login (routes/auth.ts).
app/Actions/Auth/LogoutAction.tsmodified+1-1
Changes to app/Actions/Auth/LogoutAction.ts
@@ -2,7 +2,7 @@ import type { RequestInstance } from '@stacksjs/types'
22import { Action } from '@stacksjs/actions'
33import { Auth } from '@stacksjs/auth'
44import { response } from '@stacksjs/router'
5import { clearAuthCookie } from './authCookie'
5import { clearAuthCookie } from '../../Support/authCookie'
66
77/**
88 * Project override of the framework's default LogoutAction — same token
app/Actions/Auth/RegisterAction.tsmodified+1-1
Changes to app/Actions/Auth/RegisterAction.ts
@@ -3,7 +3,7 @@ import { Action } from '@stacksjs/actions'
33import { Auth, register } from '@stacksjs/auth'
44import { response } from '@stacksjs/router'
55import { schema } from '@stacksjs/validation'
6import { buildAuthCookie } from './authCookie'
6import { buildAuthCookie } from '../../Support/authCookie'
77
88/**
99 * Account creation, registered at POST /api/auth/register (routes/auth.ts).
app/Actions/Auth/SocialCallbackAction.tsmodified+1-1
Changes to app/Actions/Auth/SocialCallbackAction.ts
@@ -6,7 +6,7 @@ import { config } from '@stacksjs/config'
66import { db } from '@stacksjs/database'
77import { response } from '@stacksjs/router'
88import { GitHubProvider, GoogleProvider } from '@stacksjs/socials'
9import { buildAuthCookie, sessionExpiryMinutes } from './authCookie'
9import { buildAuthCookie, sessionExpiryMinutes } from '../../Support/authCookie'
1010
1111function makeDriver(provider: string): GitHubProvider | GoogleProvider | null {
1212 const svc = config.services as any
app/Actions/Auth/VerifyTwoFactorLoginAction.tsmodified+1-1
Changes to app/Actions/Auth/VerifyTwoFactorLoginAction.ts
@@ -3,7 +3,7 @@ import { Action } from '@stacksjs/actions'
33import { Auth, consumeTwoFactorChallenge, verifyTwoFactorLoginCode } from '@stacksjs/auth'
44import { response } from '@stacksjs/router'
55import { schema } from '@stacksjs/validation'
6import { buildAuthCookie, sessionExpiryMinutes } from './authCookie'
6import { buildAuthCookie, sessionExpiryMinutes } from '../../Support/authCookie'
77
88/**
99 * Exchange a LoginAction 2FA challenge + TOTP code for a real session,
config/auth.tsmodified+2-2
Changes to config/auth.ts
@@ -53,7 +53,7 @@ export default {
5353 * The custom auth actions (LoginAction, RegisterAction,
5454 * VerifyTwoFactorLoginAction, SocialCallbackAction) mirror the issued
5555 * access token into the HttpOnly `auth-token` cookie (see
56 * Actions/Auth/authCookie.ts) because the dashboard is server-rendered stx
56 * Support/authCookie.ts) because the dashboard is server-rendered stx
5757 * with no client hydration and has no other way to know who is asking. Both
5858 * the cookie's Max-Age and the `oauth_access_tokens.expires_at` row are
5959 * stamped from here, and nothing extends either one — `getUserFromToken`
@@ -63,7 +63,7 @@ export default {
6363 *
6464 * This is the BASELINE only. LoginAction and VerifyTwoFactorLoginAction
6565 * pass a per-login `expiresInMinutes` from the sign-in form's "remember me"
66 * checkbox (see sessionExpiryMinutes in Actions/Auth/authCookie.ts): a week
66 * checkbox (see sessionExpiryMinutes in Support/authCookie.ts): a week
6767 * unchecked, 30 days checked. This default covers the entry points that have
6868 * no such checkbox — register, SSO — so they land on the baseline week.
6969 */
routes/auth.tsmodified+1-1
Changes to routes/auth.ts
@@ -8,7 +8,7 @@ import { response, route } from '@stacksjs/router'
88 * prefix (config/server.ts). login.stx / register.stx are now client-fetch
99 * forms that POST here with `credentials: 'same-origin'`; on success each
1010 * action returns a single HttpOnly `auth-token` cookie (see
11 * Actions/Auth/authCookie.ts) that IS the session — there is no localStorage
11 * Support/authCookie.ts) that IS the session — there is no localStorage
1212 * token, no Authorization header and no refresh exchange anywhere.
1313 *
1414 * `.skipCsrf()` stays: the endpoints are same-origin fetches, and the cookie