Skip to content

feat(users): development discovery override and OIDC test issuer for Microsoft sign-in (#879) - #922

Merged
antosubash merged 6 commits into
mainfrom
feat/issue-879-microsoft-dev-idp
Nov 11, 2026
Merged

antosubash merged 6 commits into
mainfrom
feat/issue-879-microsoft-dev-idp

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

  • New setting: oauth_microsoft_discovery_url points Microsoft sign-in at a local IdP through its discovery document.
    • It is honoured only when SM_ENVIRONMENT is explicitly development or testing. An unset variable doesn't count. Anywhere else it is ignored and users.oauth.microsoft_discovery_ignored is logged, so production sign-ins can never be sent to another IdP.
    • The discovery URL and every endpoint in it must be HTTPS, or plain HTTP to a loopback address.
  • MicrosoftDevOidc (users/oauth/microsoft_dev.py):
    • fetches the document on first use, never at boot;
    • validates ID tokens against the document's issuer, with every Microsoft tid, nonce and PKCE rule still applied;
    • when discovery fails, /login refuses with OAUTH_PROVIDER_ERROR instead of a 500.
  • Test helper: simple_module_test gains OidcTestIssuer and the oidc_test_issuer fixture (RSA key, JWKS, discovery document, sign(claims)), adding PyJWT[crypto] and cryptography to the testing package. Modules can now test an OpenID Connect sign-in without an IdP.
  • Keycloak recipe: docs/examples/keycloak-entra-realm.json is a realm with Entra-shaped claims: a fixed tid, the user id as oid, and the email as upn. The setup steps are in docs/modules/users.md, "Microsoft sign-in without Entra".
  • Docs: users README, docs/testing/fixtures.md, docs/reference/env-vars.md, framework/testing/README.md, CHANGELOG.
  • Design: docs/superpowers/specs/2026-11-11-microsoft-dev-idp-design.md.

Closes #879

Verification

  • Manual end-to-end run against the shared dev Keycloak with the shipped realm:
    • authorization code + PKCE through Keycloak's login form;
    • an ID token validated against the JWKS from discovery;
    • oid, tid and upn mapped;
    • a member on a trusted domain marked verified;
    • a wrong nonce refused.
  • Tests:
    • the issuer helper;
    • a full /login → /callback round trip through pytest-httpx;
    • a foreign issuer refused;
    • the override ignored in production and when SM_ENVIRONMENT is unset;
    • unreachable discovery and remote plain-HTTP discovery both refused cleanly.
  • Local CI: make lint passes, make test-py has 8456 passed and 28 skipped, make test-js has 907 passed.
  • Reviews: Sonnet security and maintainability (2 passes) and Codex. Fixed from review: the fail-closed environment check, the HTTPS/loopback rule, the /login 500, and a cached test key.
  • Verification report: https://claude.ai/artifact/1itnVqjLoRkJavhVF7zjBi

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. GitHub Actions was in a major outage when this was opened, so it won't merge before PR checks has actually run and passed.

https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4

An in-process OpenID Connect issuer (RSA key, JWKS, discovery document,
sign(claims)) so modules can test an OIDC sign-in without an IdP.

Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
…ycloak recipe (#879)

oauth_microsoft_discovery_url (development/testing only) builds a
MicrosoftDevOidc that reads endpoints, JWKS and issuer from a discovery
document on first use. docs/examples/keycloak-entra-realm.json emits
Entra-shaped claims; verified once against the shared dev Keycloak.

Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
The discovery override fails closed on an unset SM_ENVIRONMENT; discovery
URLs must be HTTPS or loopback HTTP; a failed discovery refuses /login with
OAUTH_PROVIDER_ERROR instead of a 500; one test signing key per process;
README and CHANGELOG shape.

Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
Docs: make dev does not set SM_ENVIRONMENT; env-vars reference notes the
fail-closed override; CHANGELOG list spacing.

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: ff42c99
Status: ✅  Deploy successful!
Preview URL: https://9272a9c5.simple-module-python.pages.dev
Branch Preview URL: https://feat-issue-879-microsoft-dev.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-11T21:00:33.280712Z ff42c99 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 e91ec4d into main Nov 11, 2026
17 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: development-only discovery override and test fixtures for Microsoft sign-in (local IdP such as Keycloak)

1 participant