Add Google sign-in for @nextgenerationofunity.org admin accounts

The login page offers "Sign in with Google" above email and password,
once GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are set on the service.
It's the server-side authorization-code flow with PKCE; the ID token
comes straight from Google's token endpoint and is checked for
issuer, audience, expiry, a verified email and the Workspace domain
(Google's hd claim).

Only accounts admin-cli has made get in. The first Google sign-in
links the account with the same email; later ones match by the link.
A disabled account, one linked to another Google account, or a
missing account is refused, with a message on the login page, and a
refused sign-in never changes the account. admin-cli list shows which
accounts are linked. Setup is in docs/google-sign-in.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-27 21:27:12 -05:00
parent 64cb2ec56a
commit d4b39251d9
8 changed files with 392 additions and 28 deletions

View file

@ -209,6 +209,7 @@ function list(db) {
const rows = db
.prepare(
`SELECT u.email, u.name, u.role, u.is_active, u.last_login_at,
u.google_sub IS NOT NULL AS google,
(SELECT COUNT(*) FROM sessions s
WHERE s.user_id = u.id AND s.expires_at > datetime('now')) AS sessions
FROM admin_users u
@ -228,7 +229,8 @@ function list(db) {
const state = r.is_active ? r.role : `${r.role} (disabled)`;
const seen = r.last_login_at ?? "never";
console.log(
`${r.email.padEnd(32)} ${state.padEnd(22)} last login ${seen.padEnd(20)} ${r.sessions} session(s)`,
`${r.email.padEnd(32)} ${state.padEnd(22)} last login ${seen.padEnd(20)} ${r.sessions} session(s)` +
(r.google ? " google linked" : ""),
);
}
}