Skip to content

feat(users): store the IdP profile on OAuth sign-in; trusted email domains (#877, #878) - #921

Merged
antosubash merged 12 commits into
mainfrom
feat/issue-877-878-oauth-profile
Nov 11, 2026
Merged

antosubash merged 12 commits into
mainfrom
feat/issue-877-878-oauth-profile

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

  • users: store the IdP profile on OAuth sign-in (full_name from name, sub/username/extra on OAuthAccount) #877, IdP profile:
    • Every provider's get_identity returns an OAuthIdentity: account id, email, proof, subject, username, display name, and extra holding Microsoft's oid/tid.
    • users_oauth_account gains subject, username, display_name, extra and last_sign_in_at, refreshed on every sign-in. Migration e480d7dd348f on the users trunk; the migration-graph test and docs/database/migrations.md are updated.
    • A new account takes full_name from the IdP's display name. oauth_sync_profile (off by default) updates it on later sign-ins. The email is never changed.
    • The admin Edit user page shows a read-only "Linked sign-ins" card, with English and German strings.
    • Google now requests names from the People API, so its display name arrives. GitHub reads /user once.
  • users: trusted email domains per OAuth provider (verify email by organisation-owned domain) #878, trusted email domains: oauth_trusted_email_domains, for example {"microsoft": ["iiasa.ac.at"]}. Matches are exact, case-insensitive, IDNA-normalised and never include subdomains.
    • microsoft: only for a member of a pinned tenant GUID (matching tid, no foreign idp, no guest #EXT# UPN in any name claim). The address is upn/preferred_username, or the email claim only when xms_edov marks its domain verified.
    • oidc: a listed domain never overrides an explicit email_verified: false.
    • Deviation from the approved design: google and github are refused at validation. Anyone can add an unverified address on any domain to those accounts, so a domain can't vouch for them. The automated security review flagged it.
  • Docs: users README, docs/modules/users.md ("Trusted email domains", "Linked identities", column list), CHANGELOG.
  • Design: docs/superpowers/specs/2026-11-11-oauth-profile-trusted-domains-design.md.

Closes #877
Closes #878

Verification

  • Tests:
    • domain matching (case, IDNA, subdomains, @ tricks);
    • settings validation, including Google and GitHub refused and the Microsoft pinned-tenant warning;
    • provider identities, including Google's primary name, a single GitHub request, Microsoft's username kept separate from a trusted email, and guest and xms_edov cases;
    • profile writes on create and on later sign-ins, with and without sync;
    • the admin view prop, and a Vitest test for the card.
  • Local CI: make lint passes, make test-py has 8444 passed and 28 skipped, make test-js has 907 passed. make ci-doctor (alembic check) and make migrations-roundtrip-pg pass.
  • Reviews:
    • Sonnet security and maintainability (2 passes).
    • Codex (3 passes), which caught a guest UPN being accepted through an alias on a trusted domain, missing Google names, an overwritten username and a double GitHub request. All are fixed.
    • The automated security review's 3 findings on domain trust were fixed before review.
  • Verification report: https://claude.ai/artifact/Dkfsx37t31NPjsCCU2in5j

Report links are Claude Artifacts and start private. The author can share them from claude.ai/code/artifacts if reviewers need access.

Test plan

  • CI is green
  • Admin → Users → a user with an SSO link shows "Linked sign-ins"

https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4

 #878)

get_identity returns an OAuthIdentity with subject, username, display name
and (Microsoft) oid/tid. oauth_trusted_email_domains lets microsoft (a member
of a pinned tenant: upn/preferred_username, or email only with xms_edov) and
oidc vouch for addresses on listed domains. Google and GitHub are refused:
anyone can add an unverified address on any domain there.

Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
OAuthAccount gains subject, username, display_name, extra and
last_sign_in_at (migration e480d7dd348f on the users trunk), refreshed on
every sign-in. A new account takes full_name from the IdP's display name;
later sign-ins update it only with oauth_sync_profile.

Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
Shared text_or_none helper; a validated ID token without sub no longer 500s;
OAuthAccount column docs.

Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
Google display name from the primary name, junk-safe; Google's explicit
unverified blocks domain trust; docs on Google names and guest UPNs.

Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: df93515
Status: ✅  Deploy successful!
Preview URL: https://ae3e2af6.simple-module-python.pages.dev
Branch Preview URL: https://feat-issue-877-878-oauth-pro.simple-module-python.pages.dev

View logs

@antosubash
antosubash merged commit 462a4cf into main Nov 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant