-
Notifications
You must be signed in to change notification settings - Fork 309
feat: add SCIM 2.0 user provisioning (EE) #1306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
brendan-kellam
wants to merge
22
commits into
main
Choose a base branch
from
brendan/scim-user-provisioning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e0b9f02
feat: add SCIM 2.0 user provisioning (EE)
brendan-kellam c09dda4
derive org from scim token
brendan-kellam ed5bc42
await onCreateUser call
brendan-kellam 5648957
nit
brendan-kellam c5439a3
Merge branch 'main' into brendan/scim-user-provisioning
brendan-kellam b5a682f
Merge branch 'main' into brendan/scim-user-provisioning
brendan-kellam 199c2bd
refactor
brendan-kellam d50d008
Add isActive to db fetches where necessary
brendan-kellam 260b789
ensureActiveMember
brendan-kellam 2234f8d
Merge branch 'main' into brendan/scim-user-provisioning
brendan-kellam e06991c
feat(web): track per-org member activity and bill only active-seen me…
brendan-kellam b9d36a3
members table v2
brendan-kellam 12355df
change isActive to suspendedAt
brendan-kellam 1d3a2fd
handle pending -> active state with a capped organization
brendan-kellam 36ac38c
tighten control under what state a member can be demoted / promoted
brendan-kellam 11b1607
add create invite dialog
brendan-kellam 0188377
s
brendan-kellam aea480b
encode filter in query params
brendan-kellam f3b4089
add export csv button
brendan-kellam b2eff5c
change order to put requests at the top
brendan-kellam d250318
docs
brendan-kellam 5e365cb
Merge branch 'main' into brendan/scim-user-provisioning
brendan-kellam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| --- | ||
| title: SCIM | ||
| sidebarTitle: SCIM | ||
| --- | ||
|
|
||
| import LicenseKeyRequired from '/snippets/license-key-required.mdx' | ||
|
|
||
| SCIM, or _System for Cross-domain Identity Management_ allows for the automation of user provisioning for your Sourcebot organization. | ||
|
|
||
| <Frame> | ||
| <img src="/images/scim_provisioning_settings.png" alt="SCIM provisioning settings in Sourcebot showing the enable toggle, connector base URL, and SCIM token list" /> | ||
| </Frame> | ||
|
|
||
| <LicenseKeyRequired feature="SCIM provisioning" /> | ||
|
|
||
| ## Overview | ||
|
|
||
| SCIM provisioning lets your identity provider manage Sourcebot organization membership automatically. When enabled, your identity provider becomes the source of truth for who should have access to your Sourcebot organization. | ||
|
|
||
| Sourcebot supports SCIM 2.0 user provisioning for identity providers such as Okta and Microsoft Entra ID. | ||
|
|
||
| ## Configure | ||
|
|
||
| 1. Navigate to **Settings -> Security**. | ||
| 2. Under the "SCIM provisioning" section, toggle the option to enable SCIM. | ||
| 3. You can now get your **SCIM connector base URL** and generate a **SCIM Bearer auth token**. These values will be needed to configure SCIM in your identity provider. | ||
|
|
||
| <Note> | ||
| When SCIM provisioning is enabled, Admins will **not** be able to manage users from within Sourcebot as they will be kept up to date through your identity provider. Role assignments can still be managed within Sourcebot. | ||
| </Note> | ||
|
|
||
| ### IdP-specific configuration notes | ||
|
|
||
| <Tabs> | ||
| <Tab title="Okta"> | ||
| <Note> | ||
| Okta does not support SCIM in an OIDC app integration. To work around this, two apps need to be created: | ||
| 1. An OIDC app used for SSO. | ||
| 2. A SAML provisioning-only app. The SSO portion of the app should not need to be functional. | ||
|
|
||
| [Learn more](https://support.okta.com/help/s/article/configure-scim-for-a-custom-oidc-app). | ||
| </Note> | ||
|
|
||
| - Follow [these instructions](/docs/configuration/idp#okta) to setup a Okta OIDC app and configure it as a SSO provider in Sourcebot. | ||
| - In Okta admin pages, create a SAML 2.0 application. This app will be used for provisioning-only and will not be used for SSO. The sign-on URL and audience URI can be set to the base URL of your deployment. | ||
| - In the General tab, click Edit and choose SCIM in the Provisioning section and Save. | ||
| - In the Provisioning tab, enter the SCIM Base connector URL from Sourcebot. | ||
| - For the Unique identifier field for users section enter **userName** | ||
| - For Supported provisioning actions, enable "Push New Users" and "Push Profile Updates" | ||
| - For Authentication mode field, choose HTTP Header and enter your SCIM token generated in Sourcebot. You can now test the configuration and save | ||
| - Lastly, return to the Provisioning tab in Okta and edit your settings under “To App” to enable the SCIM functionality needed for your Sourcebot application (Create, Update and Deactivate users) | ||
|
|
||
| <Frame> | ||
| <img src="/images/okta_scim_to_app_provisioning.png" alt="Okta provisioning To App settings showing Create Users, Update User Attributes, and Deactivate Users enabled" /> | ||
| </Frame> | ||
| </Tab> | ||
| </Tabs> | ||
|
|
||
| ## User lifecycle | ||
|
|
||
| Sourcebot represents organization users with three membership states: | ||
|
|
||
| | Sourcebot state | Access | Billing | | ||
| | --- | --- | --- | | ||
| | Pending | Can access the organization after signing in | Not billed | | ||
| | Active | Can access the organization | Billed | | ||
| | Suspended | Cannot access the organization | Not billed | | ||
|
|
||
| When a user is provisioned through SCIM, Sourcebot creates or restores their organization membership. New SCIM-provisioned users appear as **Pending** until they sign in and access the organization for the first time. | ||
|
|
||
| When a pending user signs in, Sourcebot moves them to **Active** and they count toward billing. On deployments with a hard seat cap, the user can only become active if a seat is available. | ||
|
|
||
| When your identity provider deactivates a user by sending `active: false`, Sourcebot marks the user as **Suspended**. Suspended users cannot access the organization, and Sourcebot revokes their active sessions, API keys, and OAuth tokens. | ||
|
|
||
| If your identity provider reactivates the user by sending `active: true`, Sourcebot restores their membership. Users who had already become active return to active access; users who had never signed in return to pending. | ||
|
|
||
|
|
||
| ## Roles | ||
|
|
||
| SCIM does not assign Sourcebot [roles](/docs/configuration/auth/roles-and-permissions). Users created through SCIM are added with the **Member** role. | ||
|
|
||
| Owners can promote active members to owner, or demote owners to member, from **Settings -> Members**. Sourcebot prevents changes that would leave the organization without an active owner. | ||
|
|
||
| ## Supported attributes | ||
|
|
||
| Sourcebot stores this subset of SCIM user attributes: | ||
|
|
||
| | SCIM attribute | Sourcebot behavior | | ||
| | --- | --- | | ||
| | `userName` | User email address | | ||
| | `emails` | User email address; the primary email is preferred | | ||
| | `name.formatted` | Display name | | ||
| | `displayName` | Display name fallback | | ||
| | `active` | Unsuspended or suspended membership state | | ||
| | `externalId` | Stored IdP external identifier | | ||
|
|
||
| Additional attributes may be sent by your identity provider, but Sourcebot ignores attributes it does not use. | ||
|
|
||
| ## FAQ | ||
|
|
||
| <AccordionGroup> | ||
| <Accordion title="What identity providers do you support?"> | ||
| SCIM provisioning should work with most identity providers that support SCIM user provisioning, but it has only been tested with Okta. | ||
| </Accordion> | ||
| <Accordion title="What version of SCIM do you support?"> | ||
| Sourcebot supports SCIM 2.0. | ||
| </Accordion> | ||
| <Accordion title="When do SCIM-created users become billable seats?"> | ||
| SCIM-created users become billable seats after they sign in and access the organization for the first time. Until then, they appear as pending and do not count toward billing. Suspended users also do not count toward billing. | ||
| </Accordion> | ||
| </AccordionGroup> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions
29
packages/db/prisma/migrations/20260619214548_add_scim_users_support/migration.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "Org" ADD COLUMN "isScimEnabled" BOOLEAN NOT NULL DEFAULT false; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "UserToOrg" ADD COLUMN "suspendedAt" TIMESTAMP(3), | ||
| ADD COLUMN "scimExternalId" TEXT; | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "ScimToken" ( | ||
| "name" TEXT NOT NULL, | ||
| "hash" TEXT NOT NULL, | ||
| "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "lastUsedAt" TIMESTAMP(3), | ||
| "orgId" INTEGER NOT NULL, | ||
|
|
||
| CONSTRAINT "ScimToken_pkey" PRIMARY KEY ("hash") | ||
| ); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "ScimToken_hash_key" ON "ScimToken"("hash"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "ScimToken_orgId_idx" ON "ScimToken"("orgId"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "UserToOrg_orgId_scimExternalId_idx" ON "UserToOrg"("orgId", "scimExternalId"); | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "ScimToken" ADD CONSTRAINT "ScimToken_orgId_fkey" FOREIGN KEY ("orgId") REFERENCES "Org"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
15 changes: 15 additions & 0 deletions
15
packages/db/prisma/migrations/20260624194710_add_lastactiveat_to_usertoorg/migration.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "UserToOrg" ADD COLUMN "lastActiveAt" TIMESTAMP(3); | ||
|
|
||
| -- Backfill per-membership activity from the global User.lastActiveAt. In a | ||
| -- single-tenant deployment a user belongs to exactly one org, so the global | ||
| -- timestamp is exactly the per-org timestamp. In multi-tenant deployments this | ||
| -- seeds every membership with the user's global last-active time as the best | ||
| -- available signal; the per-org value diverges naturally from the next | ||
| -- authenticated action onward. Without this, every existing membership would | ||
| -- read as "never active" (NULL) until each member's next request. | ||
| UPDATE "UserToOrg" AS uto | ||
| SET "lastActiveAt" = u."lastActiveAt" | ||
| FROM "User" AS u | ||
| WHERE uto."userId" = u."id" | ||
| AND u."lastActiveAt" IS NOT NULL; |
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.