-
Notifications
You must be signed in to change notification settings - Fork 302
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
base: main
Are you sure you want to change the base?
Changes from all commits
e0b9f02
c09dda4
ed5bc42
5648957
c5439a3
b5a682f
199c2bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 "isActive" BOOLEAN NOT NULL DEFAULT true, | ||
| 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; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -272,9 +272,12 @@ model Org { | |||||||||||||||||
| connections Connection[] | ||||||||||||||||||
| repos Repo[] | ||||||||||||||||||
| apiKeys ApiKey[] | ||||||||||||||||||
| scimTokens ScimToken[] | ||||||||||||||||||
| isOnboarded Boolean @default(false) | ||||||||||||||||||
| imageUrl String? | ||||||||||||||||||
|
|
||||||||||||||||||
| isScimEnabled Boolean @default(false) | ||||||||||||||||||
|
|
||||||||||||||||||
| /// @deprecated This property can be controlled by the environment | ||||||||||||||||||
| /// variable `REQUIRE_APPROVAL_NEW_MEMBERS`. To ensure that we use | ||||||||||||||||||
| /// the correct setting, use the helper function `isMemberApprovalRequired` | ||||||||||||||||||
|
|
@@ -397,7 +400,17 @@ model UserToOrg { | |||||||||||||||||
|
|
||||||||||||||||||
| role OrgRole @default(MEMBER) | ||||||||||||||||||
|
|
||||||||||||||||||
| /// SCIM soft-deactivation flag. When false, the membership is suspended by | ||||||||||||||||||
| /// the IdP: the user is treated as a non-member for auth purposes (see | ||||||||||||||||||
| /// `getAuthContext`) but the row is preserved so the IdP can reactivate it. | ||||||||||||||||||
| isActive Boolean @default(true) | ||||||||||||||||||
|
|
||||||||||||||||||
| /// The IdP-supplied `externalId` for this membership when provisioned via | ||||||||||||||||||
| /// SCIM. Null for members that joined through invites or self-serve sign-up. | ||||||||||||||||||
| scimExternalId String? | ||||||||||||||||||
|
|
||||||||||||||||||
| @@id([orgId, userId]) | ||||||||||||||||||
| @@index([orgId, scimExternalId]) | ||||||||||||||||||
|
Comment on lines
+410
to
+413
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enforce per-org uniqueness for SCIM
Suggested schema fix- @@index([orgId, scimExternalId])
+ @@unique([orgId, scimExternalId])📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| model ApiKey { | ||||||||||||||||||
|
|
@@ -414,6 +427,23 @@ model ApiKey { | |||||||||||||||||
| createdById String | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /// Org-scoped bearer token presented by an IdP (Okta, Entra) to authenticate | ||||||||||||||||||
| /// against the SCIM provisioning endpoints. Unlike `ApiKey`, a SCIM token is | ||||||||||||||||||
| /// not tied to a user — it acts on behalf of the SCIM integration for the | ||||||||||||||||||
| /// whole org. Only the HMAC hash of the secret is stored. | ||||||||||||||||||
| model ScimToken { | ||||||||||||||||||
| name String | ||||||||||||||||||
| hash String @id @unique | ||||||||||||||||||
|
|
||||||||||||||||||
| createdAt DateTime @default(now()) | ||||||||||||||||||
| lastUsedAt DateTime? | ||||||||||||||||||
|
|
||||||||||||||||||
| org Org @relation(fields: [orgId], references: [id], onDelete: Cascade) | ||||||||||||||||||
| orgId Int | ||||||||||||||||||
|
|
||||||||||||||||||
| @@index([orgId]) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| model Audit { | ||||||||||||||||||
| id String @id @default(cuid()) | ||||||||||||||||||
| timestamp DateTime @default(now()) | ||||||||||||||||||
|
|
||||||||||||||||||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbd: do we actually need to store a
isActivefield here?