Skip to content

feat(provisioning): add opt-in SCIM 2.0 user and group provisioning - #73

Merged
ALikesToCode merged 3 commits into
feat/saml-federationfrom
feat/scim-provisioning
Oct 9, 2026
Merged

ALikesToCode merged 3 commits into
feat/saml-federationfrom
feat/scim-provisioning

Conversation

@ALikesToCode

Copy link
Copy Markdown
Owner

Summary

Adds opt-in SCIM 2.0 provisioning of non-administrator accounts and organisation teams. With SCIM_ENABLED unset or off (the default), every /scim/v2/* route returns 404 and account creation is unchanged.

  • Settings:
    • SCIM_ENABLED. Empty means off; a malformed value is off with one warning.
    • SCIM_TRUST_CONFIG_JSON maps each organisation to a token_ref. That names the environment variable or Worker secret holding the provisioning bearer token, never the token itself.
    • A presented token must match exactly one tenant, by SHA-256 digest compared in constant time; otherwise it returns 401.
    • SCIM requires D1 for accounts and intelligence storage and CONFIG_REVISION_SYNC_ENABLED; without them it returns 503.
  • Endpoints: ServiceProviderConfig, Schemas, ResourceTypes, Users and Groups with list, get, create, PUT, PATCH and DELETE, served as application/scim+json with SCIM error bodies.
    • Pagination uses startIndex/count, with count at most 100.
    • The only filters are userName, externalId and displayName with eq; others return 400 invalidFilter.
    • meta.version is an ETag, and a stale If-Match returns 412.
  • Users:
    • Provisioned accounts are never administrators and get only the default user scopes. Environment-managed administrator names are refused.
    • The generated key is discarded: SCIM never returns or logs a credential.
    • Repeating an externalId returns the existing resource; a conflicting userName returns 409 uniqueness.
  • Deactivation: active=false or DELETE revokes the account and replaces its key hash, ending keys and sessions through the security revision. The account, external identity and usage are kept, and reactivating does not restore the old key.
  • Groups map to teams in the token's organisation through the tenant authority. Groups never grant administrator roles, and members from another tenant are rejected.

Details are in docs/scim-provisioning.md.

Wiring

  • services/user_provisioning.py gets provision_scim_user, a least-privilege creator that needs no interactive administrator session. create_user is unchanged.
  • The Worker forwards /scim/v2/* unchanged, which a test confirms.
  • The Wave 7 integration adds:
    • mounting register_scim_routes with the D1 store, account service and tenant authority;
    • the private scim endpoint and its dispatcher entry;
    • ETag/Location in the CORS expose lists.

Shared registrations

  • tests/test_scim_provisioning_worker.mjs in test:worker.
  • worker/scim-d1.mjs in the edge module inventory, and both SCIM blueprint routes in the Flask route inventory.
  • SCIM_ENABLED and SCIM_TRUST_CONFIG_JSON in the Container env keys.
  • scim_resources, scim_group_members, scim_token_digests and scim_audit in REQUIRED_D1_TABLES.

Stacked on #72

Migration numbers must be contiguous in each PR, so this branch merges feat/saml-federation (#72, migration 0035), which stacks on #71 and #70. Merge those first. The credits ledger stacks on this one.

Tests

  • tests/test_scim_provisioning.py and tests/test_scim_provisioning_worker.mjs cover:
    • scoped authentication and tenant isolation;
    • idempotent externalId;
    • PATCH operations and unsupported filters;
    • ETag 412 and pagination caps;
    • no administrator escalation;
    • deactivation invalidating keys and sessions;
    • the default off state.
  • Full Python suite: 4,922 passed, 2 skipped. ruff, mypy and bandit are clean.
  • npm run test:worker: 1,830 passed. npm run test:integration: 7 passed.
  • cf:migrations:check reports 36 contiguous, additive migrations. test:deploy, free routes, client headers and the wrangler deploy --dry-run bundle all pass.
  • tests/test_frontend_build.mjs fails locally because @tailwindcss/cli is not installed. It fails the same way on main.

Apply the migration before enabling the flag: npx wrangler d1 migrations apply multillm-intelligence --remote.

CI notes

  • GitHub python/node jobs: the dependency-audit steps fail on every branch, including main. fix(deps): clear the CI dependency audit advisories #42 fixes that.
  • Workers Builds: fails on this stack because the Wave 3 base adds the AdmissionCoordinator Durable Object migration, which wrangler versions upload cannot apply. This is expected until wrangler deploy runs on main.

This is part of Wave 7. The README line comes with the Wave 7 integration PR.

SCIM_ENABLED (off by default) serves /scim/v2 discovery, Users and Groups with
SCIM errors, ETag versions and If-Match checks, count-bounded pagination and a
small documented filter subset. A provisioning bearer token is matched by
digest against tenant-scoped secret references, and fixes the organisation.

Provisioned accounts are never administrators and receive no usable key over
SCIM. Deactivation or deletion revokes the account's key and sessions through
the security revision and keeps the account, external identity and usage.
Groups map to teams through the tenant authority. Storage is in D1
(migration 0036).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
multillm-proxy 606bba8 Oct 09 2026, 08:01 AM

@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fce603ac-f5b7-4a53-a92a-738f1ece0be2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ALikesToCode
ALikesToCode merged commit 2d9645a into feat/saml-federation Oct 9, 2026
4 of 7 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.

1 participant