WIP: FORGE-504: Sign in with gmacko via ForgeGraph's Nathan child (NATH-23) #1329

Closed
gmackie wants to merge 1 commit from FORGE-504-gmacko-sign-in into main
Owner

Kanbanger: FORGE-504 (https://tasks.gmac.io/gmacko/issue/FORGE-504). Parent: NATH-23 (Fleet Rollout of "Sign in with gmacko").

Draft (WIP), hold. This PR stays a draft until beta verification and an independent security review are done.

What

"Sign in with gmacko" (providerId nathan) for forgegraf.com. It signs in against ForgeGraph's own Nathan child, id.forgegraf.com (id.beta.forgegraf.com on beta), linked to the gmacko parent https://id.gmac.io/api/auth.

  • apps/web/src/lib/gmacko.ts: the Nathan kit, vendored unchanged from gmackie/nathan 9332fedd (PR #48, feat/NATH-23-child-kit). It runs on the Better Auth 1.6 line:
    • endpoints pinned under the issuer;
    • PKCE S256 plus a browser-bound nonce;
    • the ID token verified against the pinned JWKS, with iss, aud, azp and nonce pinned;
    • email and profile only from UserInfo for the same sub;
    • the exact redirect URI https://<host>/api/auth/oauth2/callback/nathan.
  • withGmacko (CREA-12 rules):
    • nathan is a trusted provider;
    • an account.create.before guard allows a link only when Nathan's email_verified === true and the local user's email is verified, with at most one subject per issuer, keyed issuer#sub;
    • gmacko ID tokens posted to /sign-in/social and /link-social are refused.
  • gmacko-config.ts: off unless NATHAN_ISSUER, NATHAN_CLIENT_ID and NATHAN_CLIENT_SECRET are all set (ForgeGraph secrets). A partial or malformed value disables only gmacko and logs the variable name, never the value.
  • The login route gains provider=gmacko (signInWithOAuth2, with the state and nonce cookies forwarded). The login page shows the button only when configured.

Unchanged

  • GitHub, Google, Microsoft and Apple sign-in, SSO (sso_providers), CLI device codes, PATs, and the git, registry and MCP tokens.
  • The oidcProvider and every trusted client: Forgejo, Veritas, FabForge, Preflight, NetControl, Creator, and Kanbanger's DB client. The iss workaround and the Forgejo provisioning hook are also untouched.
  • When unconfigured, provider=gmacko falls through to GitHub exactly as an unknown provider did before. The genericOAuth plugin is registered with no providers.
  • A gmacko sign-up gets no username at sign-up, like Google, Microsoft and Apple sign-ups, so its Forgejo account is created lazily (owner decision D3).

Checks (local, head e81eb8f86)

  • Nathan kit suite (node:test) against better-auth 1.6.11: 18 pass, 0 fail, 1 skipped (the 1.7-preview refusal case).
  • apps/web tsc clean, apps/storybook tsc clean, oxlint no errors.
  • apps/web vitest: 382 files, 3186 tests pass, including the new gmacko-config.test.ts (4) and api/auth/login/route.test.ts (3).
  • pnpm install --frozen-lockfile ok: the lockfile only gains importer entries for packages already locked, @better-auth/core@1.6.11 and jose@6.2.3.
  • build:worker (OpenNext) ok, 6.8 MB gzip.

Plan and owner decisions (2026-12-01)

The plan is in docs/plans/2026-12-01-forge-504-gmacko-sign-in.html.

  • D1: Forgejo moves to id.gmac.io directly. This needs a follow-up issue covering username mapping and Forgejo ACCOUNT_LINKING.
  • D2: NetControl moves to id.gmac.io directly, in its own issue.
  • D3: Forgejo accounts for gmacko sign-ups work as they do for Google, Microsoft and Apple.
  • D4: trusted clients are removed one at a time, after their app runs gmacko in production and the client has issued no tokens for 30 days.
  • D5: the beta child is provisioned once nathan #48 merges.

Remaining before ready

  1. Provision id.beta.forgegraf.com (nathan child provision|register|client|deliver), with the client starting disabled and the exact redirect https://beta.forgegraf.com/api/auth/oauth2/callback/nathan. Then set NATHAN_* on the forgegraf-beta Worker.
  2. Beta evidence:
    • a new user signs in;
    • an existing verified user lands on their own account;
    • an existing unverified user is refused;
    • a second subject from the same issuer is refused;
    • a posted ID token is refused.
  3. Independent security review.
  4. Production: id.forgegraf.com, with secrets on forgegraf and forgegraph-onebox. Merge, let CI deploy, then repeat the evidence.

🤖 Generated with Claude Code

Kanbanger: FORGE-504 (https://tasks.gmac.io/gmacko/issue/FORGE-504). Parent: NATH-23 (Fleet Rollout of "Sign in with gmacko"). **Draft (WIP), hold.** This PR stays a draft until beta verification and an independent security review are done. ## What "Sign in with gmacko" (providerId `nathan`) for forgegraf.com. It signs in against ForgeGraph's own Nathan child, id.forgegraf.com (id.beta.forgegraf.com on beta), linked to the gmacko parent https://id.gmac.io/api/auth. - `apps/web/src/lib/gmacko.ts`: the Nathan kit, vendored unchanged from gmackie/nathan 9332fedd (PR #48, feat/NATH-23-child-kit). It runs on the Better Auth 1.6 line: - endpoints pinned under the issuer; - PKCE S256 plus a browser-bound nonce; - the ID token verified against the pinned JWKS, with iss, aud, azp and nonce pinned; - email and profile only from UserInfo for the same `sub`; - the exact redirect URI `https://<host>/api/auth/oauth2/callback/nathan`. - `withGmacko` (CREA-12 rules): - `nathan` is a trusted provider; - an `account.create.before` guard allows a link only when Nathan's `email_verified === true` and the local user's email is verified, with at most one subject per issuer, keyed `issuer#sub`; - gmacko ID tokens posted to /sign-in/social and /link-social are refused. - `gmacko-config.ts`: off unless `NATHAN_ISSUER`, `NATHAN_CLIENT_ID` and `NATHAN_CLIENT_SECRET` are all set (ForgeGraph secrets). A partial or malformed value disables only gmacko and logs the variable name, never the value. - The login route gains `provider=gmacko` (`signInWithOAuth2`, with the state and nonce cookies forwarded). The login page shows the button only when configured. ## Unchanged - GitHub, Google, Microsoft and Apple sign-in, SSO (`sso_providers`), CLI device codes, PATs, and the git, registry and MCP tokens. - The `oidcProvider` and every trusted client: Forgejo, Veritas, FabForge, Preflight, NetControl, Creator, and Kanbanger's DB client. The `iss` workaround and the Forgejo provisioning hook are also untouched. - When unconfigured, `provider=gmacko` falls through to GitHub exactly as an unknown provider did before. The genericOAuth plugin is registered with no providers. - A gmacko sign-up gets no username at sign-up, like Google, Microsoft and Apple sign-ups, so its Forgejo account is created lazily (owner decision D3). ## Checks (local, head e81eb8f86) - Nathan kit suite (node:test) against better-auth 1.6.11: 18 pass, 0 fail, 1 skipped (the 1.7-preview refusal case). - `apps/web` tsc clean, `apps/storybook` tsc clean, oxlint no errors. - `apps/web` vitest: 382 files, 3186 tests pass, including the new `gmacko-config.test.ts` (4) and `api/auth/login/route.test.ts` (3). - `pnpm install --frozen-lockfile` ok: the lockfile only gains importer entries for packages already locked, `@better-auth/core@1.6.11` and `jose@6.2.3`. - `build:worker` (OpenNext) ok, 6.8 MB gzip. ## Plan and owner decisions (2026-12-01) The plan is in `docs/plans/2026-12-01-forge-504-gmacko-sign-in.html`. - **D1:** Forgejo moves to id.gmac.io directly. This needs a follow-up issue covering username mapping and Forgejo `ACCOUNT_LINKING`. - **D2:** NetControl moves to id.gmac.io directly, in its own issue. - **D3:** Forgejo accounts for gmacko sign-ups work as they do for Google, Microsoft and Apple. - **D4:** trusted clients are removed one at a time, after their app runs gmacko in production and the client has issued no tokens for 30 days. - **D5:** the beta child is provisioned once nathan #48 merges. ## Remaining before ready 1. Provision id.beta.forgegraf.com (`nathan child provision|register|client|deliver`), with the client starting disabled and the exact redirect `https://beta.forgegraf.com/api/auth/oauth2/callback/nathan`. Then set `NATHAN_*` on the forgegraf-beta Worker. 2. Beta evidence: - a new user signs in; - an existing verified user lands on their own account; - an existing unverified user is refused; - a second subject from the same issuer is refused; - a posted ID token is refused. 3. Independent security review. 4. Production: id.forgegraf.com, with secrets on forgegraf and forgegraph-onebox. Merge, let CI deploy, then repeat the evidence. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
FORGE-504: Add "Sign in with gmacko" behind NATHAN_* config, off by default
Some checks failed
CI / superseded (pull_request) Successful in 8s
CI / storybook (pull_request) Has been skipped
CI / web-build (pull_request) Has been skipped
CI / database (pull_request) Has been skipped
CI / database-d1 (pull_request) Has been skipped
CI / gitleaks (pull_request) Successful in 22s
Registry deps hash / inputs (pull_request) Successful in 45s
CI / go (pull_request) Successful in 50s
Preview / cleanup (pull_request) Has been skipped
Preview / deploy (pull_request) Has been skipped
Preview / e2e (pull_request) Has been skipped
Preview / release (pull_request) Has been skipped
CI / checks (pull_request) Successful in 2m14s
CI / unit-web (pull_request) Successful in 2m59s
CI / ci (pull_request) Failing after 13s
Registry deps hash / rebuild (pull_request) Successful in 6m39s
Registry deps hash / pnpm-deps-hash (pull_request) Successful in 2s
e81eb8f863
ForgeGraph gets a gmacko provider (providerId nathan) for NATH-23. It signs
in through ForgeGraph's own Nathan child (id.forgegraf.com, and
id.beta.forgegraf.com for beta), which is linked to the gmacko parent.

- Vendor the Nathan kit (nathan 9332fedd, PR #48) as apps/web/src/lib/gmacko.ts.
  It runs on the Better Auth 1.6 line: explicit endpoints, PKCE S256 plus a
  browser-bound nonce, an EdDSA ID token verified against the pinned JWKS,
  email only from UserInfo for the same subject, and the exact redirect
  /api/auth/oauth2/callback/nathan. The kit's own suite passes 18/18 on 1.6.11.
- CREA-12 linking via withGmacko: link only when Nathan and the local user both
  have a verified email, one subject per issuer, keyed issuer#sub, redirect
  flow only (posted ID tokens are refused).
- Off unless NATHAN_ISSUER, NATHAN_CLIENT_ID and NATHAN_CLIENT_SECRET are all
  set. A partial or malformed value disables only gmacko and logs the variable
  name, never the value. Unset, provider=gmacko falls through to GitHub as
  before, and the button is hidden.
- GitHub, Google, Microsoft, Apple, SSO, device codes, PATs and the
  oidcProvider with its trusted clients are unchanged.
- Plan and owner decisions: docs/plans/2026-12-01-forge-504-gmacko-sign-in.html

Refs NATH-23

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Closed as a duplicate of #1328 (owner decision). The plan and decisions are posted there.

Closed as a duplicate of #1328 (owner decision). The plan and decisions are posted there.
gmackie closed this pull request 2026-12-02 05:21:28 +00:00
Some checks failed
CI / superseded (pull_request) Successful in 8s
CI / storybook (pull_request) Has been skipped
CI / web-build (pull_request) Has been skipped
CI / database (pull_request) Has been skipped
CI / database-d1 (pull_request) Has been skipped
CI / gitleaks (pull_request) Successful in 22s
Required
Details
Registry deps hash / inputs (pull_request) Successful in 45s
CI / go (pull_request) Successful in 50s
Preview / cleanup (pull_request) Has been skipped
Preview / deploy (pull_request) Has been skipped
Preview / e2e (pull_request) Has been skipped
Preview / release (pull_request) Has been skipped
CI / checks (pull_request) Successful in 2m14s
CI / unit-web (pull_request) Successful in 2m59s
CI / ci (pull_request) Failing after 13s
Required
Details
Registry deps hash / rebuild (pull_request) Successful in 6m39s
Registry deps hash / pnpm-deps-hash (pull_request) Successful in 2s

Pull request closed

Sign in to join this conversation.
No description provided.