feat(sso): add safe member provisioning - #7309
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThe PR adds configurable automatic and invite-only SSO member provisioning, routing automatic admission through organization membership, billing, and session-policy controls.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/auth/sso/application/admit-sso-user.ts | Implements verified, lock-protected SSO admission and consistently pins billing decisions and seat reconciliation to the deterministically selected subscription. |
| apps/sim/lib/auth/auth.ts | Integrates application-owned SSO admission into callback processing, activates accepted organization sessions, and redirects denied callbacks with explicit errors. |
| apps/sim/lib/billing/organizations/membership.ts | Adds optional subscription pinning so capacity validation and paid-join behavior resolve the same entitled subscription. |
| apps/sim/lib/billing/organizations/seats.ts | Supports subscription-pinned Team seat reconciliation after successful automatic provisioning. |
| apps/sim/app/api/auth/sso/register/route.ts | Persists provisioning mode with domain trust and restores it during failed provider-update rollback. |
| apps/sim/ee/sso/components/sso-settings.tsx | Adds administrator controls and saved-state presentation for automatic versus invite-only provisioning. |
| packages/db/migrations/0314_superb_daimon_hellstrom.sql | Adds a non-null provisioning flag with a rollout-compatible default preserving existing automatic behavior. |
Sequence Diagram
sequenceDiagram
participant U as SSO User
participant BA as Better Auth
participant A as SSO Admission
participant DB as Organization and Billing DB
participant UI as SSO UI
U->>BA: Complete IdP authentication
BA->>A: Admit authenticated provider identity
A->>DB: Verify provider and inspect existing access
alt Existing member
A-->>BA: Activate existing organization
else Invite-only or preserved invitation/access
A-->>BA: Authenticate without new membership
else Automatic provisioning
A->>DB: Select current subscription and enforce seats
A->>DB: Create member and reconcile Team seats
A-->>BA: Activate organization session
else Admission denied
BA->>DB: Delete newly created session
BA-->>UI: Redirect with actionable error
end
Reviews (2): Last reviewed commit: "fix(sso): harden provisioning edge cases" | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed across 25 files
Tip: instead of fixing issues one by one fix them all with cubic
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
Collaborator
Author
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.
Summary
Add configurable Automatic and Invite-only SSO member provisioning. Route automatic joins through verified, seat-aware organization admission, preserve existing-member access in Invite-only mode, and upgrade Better Auth to the patched stable SSO release.
Fixes: N/A
Type of Change
Testing
bun run lintbun run lint:checkbun run check:auditsbun run apps/sim/scripts/check-block-registry.ts origin/stagingbun run check:migrations origin/stagingbunx turbo run type-check --filter=@sim/app --filter=@sim/auth --filter=@sim/dbstagingReview the fail-closed admission behavior, Team versus Enterprise seat handling, existing-member behavior in Invite-only mode, and the administrator/user error UX.
Checklist
Screenshots/Videos
Not included; the UI behavior is covered by component tests.