Skip to content

feat(users): trusted single-tenant UPN policy for Microsoft sign-in (#873) - #912

Merged
antosubash merged 6 commits into
mainfrom
feat/issue-873-entra-tenant-upn
Nov 11, 2026
Merged

antosubash merged 6 commits into
mainfrom
feat/issue-873-entra-tenant-upn

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

  • Adds oauth_microsoft_trust_tenant_upn, off by default. Today Microsoft sign-in never treats the user's email as verified, so on a site with self-signup closed nobody can sign in with Microsoft. With this setting on and oauth_microsoft_tenant set to a canonical tenant GUID, a member account's userPrincipalName counts as a verified email. The first Microsoft sign-in then links to an invited or verified local account with that address.
  • It is not trusted for guest UPNs (#EXT#), an empty Graph id or UPN, common/organizations/consumers, Microsoft's consumers tenant GUID, a domain-name tenant, or a non-canonical GUID. In those cases the setting does nothing, and with it on a users.oauth.microsoft_trust_ignored warning is logged. The mail attribute is never used.
  • api.py is unchanged: the unproven-account guard (OAUTH_ACCOUNT_NOT_VERIFIED) and the allow_signup gate still apply. Signup without allow_signup is users: SSO account provisioning is tied to local self-signup (allow_signup); add a provider-scoped setting #874.
  • Docs: the users README, docs/modules/users.md and the CHANGELOG. They include a note that turning this on trusts the tenant's admins, who can set any member's UPN. I also corrected a stale claim in docs/modules/users.md that associate_by_email is always on.
  • Design: docs/superpowers/specs/2026-11-11-entra-tenant-upn-trust-design.md.

Closes #873

Verification

  • New tests: provider identity unit tests, the policy-resolution and warning tests, and callback flow tests with allow_signup=False. The flow tests cover an invited account, a verified account, trust off, an unproven account and a guest.
  • Local CI: make lint passes, make test-py has 8347 passed and 28 skipped, make test-js has 906 passed.
  • Not browser-tested: the change is backend-only and there is no Entra tenant locally.
  • Reviews: Sonnet correctness and maintainability (2 passes) and Codex.
  • Verification report: https://claude.ai/artifact/CQfdqsSBpPgfrT2fLiSQ3M

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
  • Against a real Entra tenant: pin the tenant GUID, turn on trust, invite a member by UPN, and sign in with Microsoft while signup is closed

https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4

…873)

oauth_microsoft_trust_tenant_upn (off by default) treats a member account's
userPrincipalName as a verified email when oauth_microsoft_tenant is a GUID,
so invited and verified local accounts link on first Microsoft sign-in.
Guest (#EXT#) UPNs and empty identities stay unverified; a non-GUID tenant
logs users.oauth.microsoft_trust_ignored and keeps the old behaviour.

Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
Exclude Microsoft's consumers tenant GUID and non-canonical GUID spellings
from the trust policy; document that the policy trusts the tenant's admins;
correct the users docs on associate_by_email/is_verified_by_default.

Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
Warning text and design doc match the canonical, non-consumers GUID rule.

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: ca32507
Status: ✅  Deploy successful!
Preview URL: https://ebef5ddb.simple-module-python.pages.dev
Branch Preview URL: https://feat-issue-873-entra-tenant.simple-module-python.pages.dev

View logs

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-11T16:30:04.918686Z ca32507 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@antosubash
antosubash merged commit ad0980f into main Nov 11, 2026
41 of 47 checks 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

Development

Successfully merging this pull request may close these issues.

users: Microsoft (Entra) OAuth cannot sign in pre-approved accounts; add a trusted single-tenant UPN policy

1 participant