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
.env.productionmodified+4-1
Changes to .env.production
@@ -97,4 +97,7 @@ QUEUE_WORKER_CONCURRENCY="encrypted:v2:eyJ2IjoyLCJlcGsiOiJNQ293QlFZREsyVnVBeUVBV
9797# Reports this app's own errors to bughq (project: loghq).
9898BUGHQ_KEY="encrypted:v2:eyJ2IjoyLCJlcGsiOiJNQ293QlFZREsyVnVBeUVBQ212TlNiUnNvcHNJa2plZlJSMUJ6bXRVVG5zWVNqVVpxenRJTTNGQXFDVSIsInNhbHQiOiJnaUNHWVJEZkc4WUJVc3pRNG9UQ2FRIiwibm9uY2UiOiJFS3BVNWZJakdrSzlPWXh1IiwiY2lwaGVydGV4dCI6ImxIc1J2OXRPUjZlTGRrSHJmYk11R0NIOTVUYVpKVklEXzFReFJTZjFZRWU2UExjeW83LTdMUEp3QzNFd210TTlkcFJsYm80eDlEdWkxeWgwVkJDYVZsLXAtblB6TXciLCJ0YWciOiJ6dVJQdjFXMGZrcVc4OF9UOXhkZU53In0"
9999
100ANALYTICSHQ_APP_ID="encrypted:v2:eyJ2IjoyLCJlcGsiOiJNQ293QlFZREsyVnVBeUVBZC1VY3h6RnZGYlJFamlPR3pzdXNoV0w2aUZJTV9HZWZSaG5HaXBnUDJDTSIsInNhbHQiOiJQa3cwYU5uRnptaks4YlpTYnRBMFJRIiwibm9uY2UiOiJmcXpzLU1jSzB6YTFFZzVTIiwiY2lwaGVydGV4dCI6IkZ0UXhoYUhzVlRzU1p3cExIX1JuZmpvWk85XzdDeG82IiwidGFnIjoiSzhjVHk2eHE1OEtwc0c4UDgyYjBqUSJ9"⧵
100ANALYTICSHQ_APP_ID="encrypted:v2:eyJ2IjoyLCJlcGsiOiJNQ293QlFZREsyVnVBeUVBZC1VY3h6RnZGYlJFamlPR3pzdXNoV0w2aUZJTV9HZWZSaG5HaXBnUDJDTSIsInNhb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G9HdVN1IiwiY2lwaGVydGV4dCI6Ijk3cEF6N3ZlMFNOMDNoY05UdzhmTXpWbWNBOCIsInRhZyI6InpKSTdJdHp3aEREM0ZEekVsUFdFZHcifQ"
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,
app/Actions/Auth/authCookie.ts app/Support/authCookie.tsrenamed+0-0

Renamed from app/Actions/Auth/authCookie.ts. The contents are unchanged.

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 */
config/services.tsmodified+3-3
Changes to config/services.ts
@@ -54,21 +54,21 @@ export default {
5454 teamId: String(env.APPLE_TEAM_ID || ''),
5555 keyId: String(env.APPLE_KEY_ID || ''),
5656 privateKey: String(env.APPLE_PRIVATE_KEY || ''), // literal \n newlines allowed
57 redirectUrl: String(env.APPLE_REDIRECT_URL || 'http://localhost:3000/auth/apple/callback'),
57 redirectUrl: String(env.APPLE_REDIRECT_URL || `${oauthBase()}/api/auth/apple/callback`),
5858 scopes: ['name', 'email'],
5959 },
6060
6161 facebook: {
6262 clientId: String(env.FACEBOOK_CLIENT_ID || ''),
6363 clientSecret: String(env.FACEBOOK_CLIENT_SECRET || ''),
64 redirectUrl: String(env.FACEBOOK_REDIRECT_URL || 'http://localhost:3000/auth/facebook/callback'),
64 redirectUrl: String(env.FACEBOOK_REDIRECT_URL || `${oauthBase()}/api/auth/facebook/callback`),
6565 scopes: ['email', 'public_profile'],
6666 },
6767
6868 twitter: {
6969 clientId: String(env.TWITTER_CLIENT_ID || ''),
7070 clientSecret: String(env.TWITTER_CLIENT_SECRET || ''),
71 redirectUrl: String(env.TWITTER_REDIRECT_URL || 'http://localhost:3000/auth/twitter/callback'),
71 redirectUrl: String(env.TWITTER_REDIRECT_URL || `${oauthBase()}/api/auth/twitter/callback`),
7272 scopes: ['tweet.read', 'users.read', 'offline.access'],
7373 },
7474
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