spec: console sign-in with Apple, Google and GitHub (rev 1 draft)
Linked sign-in methods and merging, device-first button, providers off unless configured.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+468
−0
docs/superpowers/specs/2026-11-02-console-social-signin-design.md+468 −0
Intent
Attributed to this commit: 21.9 g CO₂e (1,303,618 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-console-social-signin, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/specs/2026-11-02-console-social-signin-design.md b/docs/superpowers/specs/2026-11-02-console-social-signin-design.md| new file mode 100644 |
| index 000000000..1ef1bebad |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-11-02-console-social-signin-design.md |
| @@ -0,0 +1,468 @@ |
| +# Console sign-in with Apple, Google and GitHub, with linked sign-in methods and merging |
| + |
| +Status: rev 1, 2026-11-02, draft for Paul's approval. Follows |
| +[console email sign-in](2026-10-21-console-email-signin-design.md), whose |
| +sign-in flow, sessions and step-up this extends. |
| + |
| +## 1. Why |
| + |
| +Today the console has one way in: type an address, then get a link and code |
| +by email, or go to Keymail if it is a Keymail address. That works, but most |
| +people expect "Continue with Apple / Google / GitHub", and a magic link is |
| +slower than a tap, especially on a phone. Carloku is the general-use flagship, |
| +so its front door should look like every other modern product's. |
| + |
| +Success: |
| + |
| +- On carloku.com, a new person can sign up with Apple, Google or GitHub in |
| + one tap plus the provider's own consent screen. A returning person signs in |
| + the same way. |
| +- The page puts the button for the person's device first, as Eleven does: |
| + Apple on a Mac, iPhone or iPad, Google on Android or ChromeOS, and email |
| + everywhere else. Once someone has signed in, the method they used last comes |
| + first. |
| +- A console with no provider configured, for example a self-hoster's, shows |
| + exactly today's page. A console with only some providers configured shows |
| + only those buttons. |
| +- One person can have several sign-in methods, and two console people who |
| + turn out to be the same human can merge. That fixes Apple's Hide My Email |
| + case: the relay address and the real address end up as one person. |
| + |
| +## 2. What Paul decided (2026-11-02) |
| + |
| +- **P1. This is about the console's own sign-in and sign-up**, not about apps |
| + hosted on the platform. |
| +- **P2. "Default for the platform" means the device**, as on Eleven: the |
| + matching provider's button comes first, then the others, with the email box |
| + still there. |
| +- **P3. Each provider is on only when it is configured.** A console with none |
| + set up stays email-only. |
| +- **P4. Carloku uses its own Apple, Google and GitHub registrations.** |
| + Self-hosters register their own, because every console has a different web |
| + address and redirect URL. |
| +- **P5. A provider sign-in lands on the person for the email address the |
| + provider vouches for.** A first sign-in creates the person, as an email link |
| + does today. (§6.2 narrows how far a provider's word on an address is |
| + trusted.) |
| +- **P6. Re-confirmation uses the same provider where the provider can do a |
| + fresh login** (Google can). Where it can't (GitHub, Apple), it falls back to |
| + an emailed code. |
| +- **P7. People can merge two console identities into one**, as on Eleven, so |
| + Hide My Email and similar cases don't strand anyone. Merging needs a fresh |
| + confirmation of both sides. The person chooses which address stays as the |
| + contact address. Team memberships, sessions and CLI logins move across, and |
| + where both were in the same team the higher role wins. Past activity keeps |
| + the address it was recorded under. |
| +- **P8. People can add and remove sign-in methods** from Your settings, but |
| + can never remove the last one. |
| + |
| +## 3. Goals, non-goals, anti-goals |
| + |
| +Goals: |
| + |
| +- Apple, Google and GitHub sign-in and sign-up on the console's front page, |
| + on the CLI approval page's sign-in, and wherever else the console asks |
| + someone to sign in. |
| +- Device-first ordering plus remembering the last method used. |
| +- A person model with several sign-in methods each, plus link, unlink and |
| + merge. |
| +- Step-up re-confirmation for each new method (P6). |
| +- Per-provider configuration that is all-or-nothing. A partly configured |
| + provider stops the console at start-up, so nobody ever sees a button that |
| + can't work. |
| + |
| +Non-goals: |
| + |
| +- Microsoft, passkeys and other providers. The design should make adding one |
| + a small change, but this work adds three. |
| +- Social sign-in for apps hosted on the platform (P1). |
| +- A central sign-in relay shared by many consoles. Each console is its own |
| + relying party with its own registrations (P4). |
| +- Splitting a merged person apart again. A merge is final. The confirmation |
| + screen says so. |
| +- Changing who can sign in. Sign-up stays open and rate-limited, as ruled for |
| + email (email-signin R2). |
| + |
| +Anti-goals (a failure even if it works): |
| + |
| +- **A button that fails because the provider isn't configured.** Eleven's |
| + home page has this bug. Here, the console only offers what it has. |
| +- **A provider becoming a way into someone else's person.** A provider's |
| + claim about an email address must never attach to a person unless that |
| + provider is trusted for that address (§6.2). Linking a provider to an |
| + existing person, and merging, always need a fresh confirmation of the |
| + person being joined. |
| +- **A step-up downgrade.** A session must never re-confirm with something |
| + weaker than the email-signin spec already allows. A Keymail session still |
| + re-confirms with Keymail (email-signin §6). |
| +- **A merge that leaves orphaned rows.** Every table keyed by a person's |
| + address has a declared merge rule, and a test fails when a new one doesn't |
| + (§7.3). |
| +- **Storing more about people than we need.** We keep the provider's subject |
| + ID, the email it vouched for, and a display label (for example the GitHub |
| + login). We don't keep names, avatars or provider tokens after sign-in. |
| + |
| +## 4. How it works for a person |
| + |
| +### 4.1 The front page |
| + |
| +The front page has one primary button, a list of other ways to sign in, and |
| +the email field: |
| + |
| +- **Primary:** the configured provider that matches the device (P2). If the |
| + person signed in on this browser before, their last-used method comes |
| + first instead. That comes from a small, non-identifying cookie that names |
| + only the method, such as `google`. |
| +- **Others:** every other configured provider as a secondary button. |
| +- **Email:** the existing address field, unchanged in behaviour. A Keymail |
| + address still goes to Keymail. |
| + |
| +When no provider is configured, the page is today's page byte for byte, apart |
| +from template whitespace. |
| + |
| +The page has to work without JavaScript, so the device is worked out on the |
| +server from `Sec-CH-UA-Platform` where the browser sends it, and from |
| +`User-Agent` otherwise. If neither gives an answer, the primary is email. |
| + |
| +### 4.2 Sign-up and sign-in are one step |
| + |
| +Pressing a provider button runs that provider's flow (§5). When it comes back: |
| + |
| +1. If this provider identity is already linked to a person, that person is |
| + signed in. |
| +2. Otherwise, if the provider vouches for an address it is trusted for |
| + (§6.2), and a person already has that address as a sign-in method, the |
| + provider identity is linked to that person and they are signed in. An |
| + email goes to that address saying a new sign-in method was added, with a |
| + way to remove it. |
| +3. Otherwise, if the address is trusted but belongs to nobody, a new person |
| + is created with that address as their contact address. This goes through |
| + the same first-landing path as email sign-up, which mints the personal |
| + account and applies plan defaults, and under the same sign-up rate limits. |
| +4. Otherwise (the address isn't one the provider is trusted for), the |
| + console asks for a one-time emailed code to that address before doing |
| + step 2 or 3 (§6.2). If the console has no mailer, it says it can't finish |
| + this sign-in and suggests another method. |
| + |
| +All four steps end in the existing `finishSignin` tail (session, cookies, |
| +`next`). The session's `method` records the provider. |
| + |
| +### 4.3 Your settings: sign-in methods |
| + |
| +"Your settings" gains a "Sign-in methods" section above "Command-line access" |
| +that lists each method: its kind, its label (address, or the GitHub login and |
| +the email it vouched for), when it was added, and when it was last used. From |
| +there a person can: |
| + |
| +- **Add a method.** They confirm freshly with their current session's method, |
| + then run the new provider's flow (or, for an email address, receive a link |
| + or code). If the identity already belongs to another person, the console |
| + offers a merge (§7) and doesn't link it silently. |
| +- **Remove a method.** This needs a fresh confirmation, and is refused when |
| + it is the last one. Removing the method behind the contact address asks |
| + the person to pick a new contact address first. |
| +- **Change the contact address** to any email-type address among their |
| + methods, including one a provider vouched for under §6.2. This is the |
| + address invites, notices and step-up emails go to. |
| + |
| +Every add, remove, merge and contact change sends a notice to the contact |
| +address (and, for a change of contact, to the old one too). |
| + |
| +### 4.4 Invites |
| + |
| +An invite is still sent to an address. A signed-in person can accept an |
| +invite addressed to any address they hold as a method, or that a provider |
| +vouched for under §6.2. They no longer have to be signed in "as" exactly |
| +that address. The seat and billing gates on accepting stay as they are. |
| + |
| +## 5. The three providers |
| + |
| +All three use the authorization-code flow with `state` and PKCE (S256), |
| +reusing the console's existing auth-cookie pattern (`keymail.go`'s |
| +`NewVerifier`, `ChallengeS256` and the `carlos_console_auth` state and |
| +verifier cookie). Apple and Google also carry an OIDC `nonce` that is checked |
| +in the ID token. Codes are exchanged server-to-server over TLS, so the ID |
| +token received straight from the provider's token endpoint can be trusted |
| +from TLS (OIDC Core §3.1.3.7). The builder may also verify signatures against |
| +JWKS. The builder decides which, but must state the choice and test it. |
| + |
| +Each provider has a sign-in callback and a step-up callback, following the |
| +Keymail split (`/auth/callback`, `/auth/stepup/callback`), for example |
| +`/auth/google/callback`. The builder picks the paths. Self-hosters register |
| +them, and the docs list them. |
| + |
| +The flow code has one small provider interface (authorize URL, exchange, |
| +identity out), so a fourth provider is one new file. Keymail stays as it is |
| +and isn't moved onto this interface in this work. |
| + |
| +### 5.1 Google |
| + |
| +- OIDC, scope `openid email`. Identity is `sub`. The address is `email` when |
| + `email_verified` is true. |
| +- Step-up: re-run with `prompt=login` and `max_age`, then check `auth_time` |
| + in the ID token, the same way Keymail step-up checks it. |
| +- Config: `CARLOS_CONSOLE_GOOGLE_CLIENT_ID`, |
| + `CARLOS_CONSOLE_GOOGLE_CLIENT_SECRET`. |
| + |
| +### 5.2 Apple |
| + |
| +- Sign in with Apple on the web, using a Services ID and scope `email` (and |
| + `name` is not requested, see §3). Apple needs `response_mode=form_post` |
| + when any scope is requested, so the callback is a **cross-site POST**. The |
| + existing auth cookie is `SameSite=Lax` and won't come with it. The Apple |
| + flow therefore needs its own state cookie with `SameSite=None; Secure`, or |
| + state held on the server and found by the `state` value. The builder |
| + chooses. Either way, the CSRF and state checks must hold, and there must be |
| + a test that runs the callback as a cross-site POST. |
| +- The client secret is an ES256 JWT signed with the team's `.p8` key. Its |
| + lifetime is at most six months, so it is minted on demand and cached, never |
| + configured as a fixed string. |
| +- Identity is `sub`. The address is `email` when `email_verified` is true. |
| + This may be a `privaterelay.appleid.com` address, which is a real, |
| + deliverable address and is treated like any other. |
| +- Step-up: Apple has no reliable forced re-login, so step-up is by emailed |
| + code to the person's contact address (P6). That address may be an Apple |
| + relay address. |
| +- **Mail to relay addresses only arrives if the sending domain is registered |
| + with Apple's Private Email Relay** (Apple Developer account, "Sign in with |
| + Apple for Email Communication", with SPF and DKIM passing). For Carloku |
| + that means registering `noreply@carloku.com` / `carloku.com`. The self-host |
| + docs say the same for theirs. |
| +- Config: `CARLOS_CONSOLE_APPLE_SERVICES_ID`, `CARLOS_CONSOLE_APPLE_TEAM_ID`, |
| + `CARLOS_CONSOLE_APPLE_KEY_ID`, `CARLOS_CONSOLE_APPLE_KEY` (the `.p8` PEM |
| + text). |
| + |
| +### 5.3 GitHub |
| + |
| +- A GitHub OAuth App (not a GitHub App), scope `user:email`, with PKCE. |
| + Identity is the numeric user `id`, never the login, which can change. The |
| + label is the login. The address is the primary, verified entry from |
| + `/user/emails`. If there is none, the sign-in stops and asks the person to |
| + verify an email on GitHub or use another method. |
| +- The provider access token is used for those two calls and then dropped, |
| + never stored. |
| +- Step-up: GitHub has no forced re-login, so step-up is by emailed code |
| + (P6). |
| +- Config: `CARLOS_CONSOLE_GITHUB_CLIENT_ID`, |
| + `CARLOS_CONSOLE_GITHUB_CLIENT_SECRET`. |
| + |
| +### 5.4 Configuration and secrets |
| + |
| +- Each provider's settings are all-or-nothing. All set turns the provider on, |
| + none set turns it off, and some set stops the console at start-up with an |
| + error naming the missing settings. |
| +- The settings are read in `cmd/console/main.go` with the others and listed |
| + in its header comment. Until #453 lands, they are delivered the way |
| + `CARLOS_STRIPE_*` is today, through the console unit's environment file. |
| + Once #453 lands, the secret ones (client secrets, the Apple key) go |
| + through `carlos secrets set -app console`, sealed to the console-only key. |
| + Nothing in this design depends on #453. |
| +- Secrets never appear in logs, error messages, the ops pages or the |
| + rendered page. |
| + |
| +## 6. Identity model |
| + |
| +### 6.1 People and sign-in methods |
| + |
| +The person stays keyed by their address in `users.address`, which is now |
| +called the **contact address**. Everything downstream that keys on it |
| +(memberships, CLI tokens, sessions, alert subscriptions, app stars and so |
| +on) is unchanged. So this design adds a mapping and doesn't rewrite the |
| +schema. |
| + |
| +A new table, `sign_in_methods`, is keyed by `(kind, subject)`: |
| + |
| +- `kind`: `email`, `keymail`, `google`, `apple` or `github`. |
| +- `subject`: the lower-cased address for `email` and `keymail`, and the |
| + provider's stable ID for the rest. |
| +- `address`: the person, which is the `users.address` it signs in to. |
| +- `vouched_email`: for providers, the verified address the provider gave |
| + most recently, together with whether it is trusted under §6.2. |
| +- `label`, `added_at`, `last_used_at`. |
| + |
| +Migration: every existing user gets one method row for their own address, |
| +`keymail` if the address is a Keymail address (`keymailAddress`), otherwise |
| +`email`. This is additive and idempotent, as the store's migration rule |
| +requires. |
| + |
| +Resolving a sign-in, by any method, means looking up `(kind, subject)` and |
| +signing in as the `address` found. An email link to an address that is |
| +another person's method after a merge therefore lands on the surviving |
| +person. An email link to an address that is nobody's method creates a person, |
| +as it does today. |
| + |
| +`sessions.method` gains `google`, `apple` and `github`. The step-up gate |
| +branches on all five, and an unknown value still fails closed |
| +(`stepup.go:295-306`). |
| + |
| +### 6.2 When a provider's word on an address is trusted |
| + |
| +Provider-verified emails aren't equally strong. A GitHub account can keep a |
| +"verified" work address long after its owner has left the company. Linking |
| +or creating a person by email (§4.2 steps 2 and 3) only trusts the provider |
| +for these cases: |
| + |
| +- **Google:** `email_verified` is true, and either the address is |
| + `@gmail.com` or the ID token carries an `hd` (Workspace) claim that equals |
| + the address's domain. This follows Google's own guidance on which emails |
| + Google is authoritative for. |
| +- **Apple:** `email_verified` is true. Apple confirms both real addresses and |
| + the relay addresses it issues. |
| +- **GitHub:** never on its own. A GitHub sign-in whose address would attach |
| + to an existing person, or create a new one, first needs a one-time emailed |
| + code to that address (§4.2 step 4). After that, the GitHub identity is |
| + linked and later sign-ins go straight through (§4.2 step 1). |
| + |
| +An untrusted address is never used to reach a person or accept an invite |
| +until it has been confirmed once by email. |
| + |
| +## 7. Merging |
| + |
| +### 7.1 When it is offered |
| + |
| +The console offers a merge when someone signed in as person A tries to add a |
| +method that already belongs to person B. This happens from Your settings, and |
| +also from the Hide My Email sign-in. For that case, Your settings has an |
| +"I already have an account with another address" action, which runs a |
| +sign-in by the other method in a step-up-style flow. |
| + |
| +### 7.2 What the person sees and confirms |
| + |
| +1. A fresh confirmation of A (A's session method). |
| +2. A fresh confirmation of B, by signing in with B's method in the step-up |
| + flow, never by being signed in as B elsewhere. |
| +3. A summary: B's teams and roles, CLI logins and open invites that will |
| + move, and a choice of which address stays as the contact address (A's or |
| + B's). |
| +4. Confirm. The summary says a merge can't be undone. |
| + |
| +The merge happens in one store transaction. Afterwards, both people's |
| +methods point to the survivor, the other `users` row is gone, and notices go |
| +to both former contact addresses. |
| + |
| +### 7.3 The merge registry |
| + |
| +Every table with a column that holds a person's address declares one rule: |
| + |
| +- **move**: rewrite the address to the survivor's. Examples are |
| + `cli_tokens`, `sessions`, `app_stars` and alert subscriptions. |
| +- **union**: move, but resolve key clashes. `memberships` keeps the higher |
| + role per team (owner beats member). If both are members of a paid team, |
| + the merge must not leave a seat billed twice, and the builder settles seat |
| + counts with the billing code's existing rules. |
| +- **history**: leave as recorded. Examples are `audit`, the `*_by` columns |
| + and billing records. |
| +- **refuse**: block the merge, with a clear reason, while a row of this kind |
| + exists. An example is a live pending action or step-up for B. |
| + |
| +A test reads the live schema, finds every column that holds a person's |
| +address (by name: `address`, `owner_address`, `*_by`, `invited_by`, and any |
| +the registry adds), and fails if a table isn't in the registry. That stops a |
| +future table from silently orphaning rows on a merge. |
| + |
| +The `grants` table (Keymail grant per address) and `owners` (legacy) need |
| +their own rules. The builder sets them from what the code still reads, and |
| +says so in the plan. |
| + |
| +## 8. Re-confirmation (step-up) |
| + |
| +- `keymail`: unchanged. |
| +- `email`: unchanged (fresh link or code to that address). |
| +- `google`: re-run Google with `prompt=login` and `max_age`, then check |
| + `auth_time` and that `sub` matches the session's method. |
| +- `apple` and `github`: emailed code to the person's contact address (P6). |
| + |
| +This isn't a downgrade (§3), because email is already an allowed way to sign |
| +in for these people. A console with no mailer can't step up `apple` or |
| +`github` sessions, so for those people sensitive actions are refused with a |
| +message that says why. The console's start-up log warns when Apple or GitHub |
| +is on without a mailer. |
| + |
| +The CLI approval page (`authcli.go`) needs nothing new beyond this: it uses |
| +the same session and the same step-up gate. |
| + |
| +## 9. Rate limits and abuse |
| + |
| +- Provider sign-ups count against the same new-person limits as email |
| + sign-up (email-signin §7). |
| +- Provider callbacks are limited per client IP, as the email submit is. |
| +- §4.2 step 4 and §6.2 codes use the existing email-challenge store and its |
| + caps. |
| +- A provider error, or a state or nonce mismatch, shows one plain |
| + "That sign-in didn't work. Try again." page and logs a reason code, never |
| + the provider's raw response. |
| + |
| +## 10. Copy |
| + |
| +New on-screen text includes: the three buttons, the "other ways to sign in" |
| +heading, the "Sign-in methods" section and its actions, the merge screens, |
| +the confirmation-code request for §4.2 step 4, the GitHub "no verified email" |
| +message, the "this console can't finish this sign-in" message, and the |
| +notices. All of it goes through copy review before it goes into templates or |
| +`signincopy.go`, in the house voice (no em dashes). Provider button text and |
| +logos follow each provider's brand guidelines, which are strict for Apple. |
| + |
| +## 11. Tests that prove it |
| + |
| +- Each provider runs against a fake provider (an httptest authorize, token |
| + and user/JWKS server), wired through the real console handlers, not a |
| + stubbed handler: |
| + - first sign-in creates a person |
| + - second sign-in finds the same person |
| + - state, nonce and PKCE mismatches are refused |
| + - an unverified email is refused |
| + - the Apple cross-site POST callback works with real cookie attributes |
| +- Configuration: none set gives today's page (golden compare), all set shows |
| + the button, some set means start-up fails and names the missing setting. |
| +- §6.2: a GitHub address matching an existing person needs the code. A |
| + Google non-Gmail address without `hd` needs the code. A Google `hd` match |
| + and an Apple verified address don't. |
| +- Merge: the registry completeness test (§7.3). A merge with overlapping |
| + teams keeps the higher role. CLI tokens keep working for the survivor. Old |
| + sessions of B now act as the survivor. A refused merge changes nothing. |
| +- Step-up per method, including the Google `auth_time` check and the |
| + no-mailer refusal for Apple and GitHub. |
| +- Device ordering: a table of user agents and `Sec-CH-UA-Platform` values |
| + against the expected primary. |
| + |
| +## 12. Rollout |
| + |
| +The code is dormant until configured, so it can merge on review and CI under |
| +the standing rule, then ship in a normal release, dev first. |
| + |
| +What Paul does outside the repo (the "platform default" registrations, P4): |
| + |
| +1. **Google:** create an OAuth client (Web) in a Carloku Google Cloud |
| + project, add the carloku.com redirect URLs, and publish the consent screen |
| + (in-production status, with the app name, logo and privacy link). |
| +2. **Apple:** in the Apple Developer account, create a Services ID with the |
| + carloku.com domain and return URL and a Sign in with Apple key (`.p8`), |
| + and register carloku.com for Private Email Relay. |
| +3. **GitHub:** create an OAuth App under the `carlosframework` org with the |
| + carloku.com callback URL. |
| +4. Put the secrets in 1Password and deliver them to the flagship console's |
| + environment (or through `carlos secrets set` once #453 is in), then |
| + restart it on a roll. |
| + |
| +Dev gets its own registrations pointing at the dev console's address, so it |
| +can be checked end to end before flagship. Live checks on each: sign up with |
| +each provider, sign in again, link a second method, merge a Hide My Email |
| +person into a real-address person, approve a CLI login after each kind of |
| +sign-in, and trigger a step-up with each kind. |
| + |
| +Self-hosters get a docs page: what to register with each provider, the |
| +callback paths, the settings, and the Apple relay step. |
| + |
| +## 13. Left to the builder |
| + |
| +- Callback paths, table and column names, and the provider interface's |
| + shape. |
| +- TLS-trusted ID tokens or JWKS verification (§5), stated and tested. |
| +- How the Apple flow keeps state across the cross-site POST (§5.2). |
| +- The merge rules for `grants` and `owners` (§7.3), and seat settlement for |
| + shared paid teams. |
| +- How the provider buttons are drawn (inline SVG, assets), within the |
| + providers' brand rules. |
| +- Splitting this into plans. A natural cut: (1) the person and method model, |
| + migration, invites by any held address, and Your settings listing; (2) |
| + Google and GitHub with step-up; (3) Apple; (4) link, unlink and merge. |