Repository navigation
feat(auth): add SCIM 2.0 user provisioning - #456
Merged
Merged
Conversation
Nothing tells an instance that a person was removed: eligibility is checked at login only, so browser sessions and MCP tokens outlive the removal. An install also cannot have its first administrator created by automation. FANOUT_SCIM_TOKEN enables POST, GET and PATCH on the SCIM Users resource. The account and its identity (configured issuer, externalId) are written in one transaction, so a crash cannot leave an unlinked account for a later login to claim by email. Requests are safe to repeat: a POST for a known identity returns the account unchanged, and a PATCH that changes nothing writes nothing. Deactivation also revokes OAuth tokens. The per-request status check stops them during suspension but would let them work again after reactivation. With a token set there is no setup banner and the setup route returns 410. Without one, SCIM paths are classified as before. Closes #442
… out of logs The request log recorded the full URI, so a SCIM filter put an email address or subject in the logs. SCIM requests are now logged without their query. Only SCIM deactivation revoked OAuth tokens, so suspending from the browser route left tokens that worked again after reactivation. Every transition out of active now revokes them. A repeated SCIM deactivation also removes any session or credential still live on an already-suspended account.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #442
Nothing tells an instance that a person was removed: eligibility is checked at login only, so browser sessions and MCP tokens outlive the removal. An install also cannot have its first administrator created by automation. This adds SCIM 2.0 provisioning, authenticated by a new secret setting,
FANOUT_SCIM_TOKEN(_FILEsupported). It requires OIDC mode and at least 32 characters.What changed
POST /scim/v2/Userscreates an account with its role and links(configured issuer, externalId)in one transaction with the audit events.GET /scim/v2/Users?filter=finds an account byexternalId eqoruserName eq. Any other filter returnsinvalidFilter.GET /scim/v2/Users/{id}reads one.PATCH /scim/v2/Users/{id}changesactive, the role, the email anddisplayName.application/scim+jsonand the RFC 7644 error format./api/auth/setupreturns 410, and/api/auth/statusreportssetup_required: false.Behaviour changes outside SCIM
cmd/fanouttoapi.RequestLogger. It behaves the same except that/scim/v2requests are logged without their query string, because a filter holds an email address or subject.Decisions to review
active: falseon an account that still has live sessions, tokens or codes: those are removed and asession.revokedevent is written.BEGIN IMMEDIATEtransaction and shares the empty-database check with setup. A non-administrator or a suspended administrator gets 409 rather than 403, so a provisioner can retry once the administrator exists. A concurrent administrator that loses the check is created normally.rolesis required on POST. A missing role returns 400 rather than falling back to a default.userNameis the email address. Ifemailsis sent, its primary value must match.Not included
There is no PUT, no DELETE, no
Groups, and noServiceProviderConfig,SchemasorResourceTypesdiscovery. A GET without a filter returnsinvalidFilter, and patch paths with a value filter are refused. Some standard clients need one or more of these (for example, a connection test that lists users without a filter). The issue did not ask for them. There is no rate limit on failed token attempts; the token is at least 32 characters.Verification
Run on the pushed commit:
just checkpasses.just test-racepasses for the whole module.-race.just e2ewas not run.Atomicity is tested with a SQLite trigger that fails the identity or audit insert inside the real transaction. Race tests use a file database, because the in-memory database has one connection and would hide races. I removed each guard in turn (the write lock, the last-administrator check, OAuth revocation, convergence, the MCP status check and the log redaction) and confirmed a test fails without it.
I did not test against a real identity provider or run the binary end to end. The tests go through HTTP handlers and a real database.