feat(sso): let organizations require single sign-on - #7881
Conversation
Adds an organization setting that refuses password and email-code sign-in for members, enforced when a session is created so enabling it signs nobody out. Owners keep every sign-in method as a break-glass path, and the requirement stops enforcing if no identity provider on a verified domain is left to satisfy it.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
There was a problem hiding this comment.
1 issue found across 24 files
Confidence score: 4/5
- In
apps/sim/ee/sso/hooks/sso-policy.ts, provider or verified-domain changes may leavehasVerifiedProviderstale for up to 60 seconds, causing the settings control to show an outdated state; invalidatessoKeys.policywhen those mutations complete.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/ee/sso/hooks/sso-policy.ts">
<violation number="1" location="apps/sim/ee/sso/hooks/sso-policy.ts:26">
P2: When a provider or verified domain changes, this query can keep `hasVerifiedProvider` stale for up to 60 seconds because those mutations do not invalidate `ssoKeys.policy`. The settings control can therefore advertise an outdated requirement state or allow an enable attempt that the API immediately rejects; invalidate the policy query from provider/domain mutations when their capability changes.</violation>
</file>
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Fix all with cubic | Re-trigger cubic
- Let an admin turn the requirement off after the organization loses its SSO entitlement, so a restored entitlement cannot silently resume it - Fail closed when the requirement cannot be read: a failed lookup no longer admits a password sign-in - Invalidate the policy cache when a provider is deleted or a domain's verification changes, on the server and in the query client - Report whether the stored requirement is actually enforced, and say so in the settings copy
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 28 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Fix all with cubic | Re-trigger cubic
… case - Replace the hand-rolled route guards with organization operations, the pattern the SSO domain already uses for its primary-provider change - Drop the multi-membership scan: users belong to at most one organization, the same assumption the expiry clamp makes - Match the provider check to what sign-in resolution actually requires, so a capable provider is never read as incapable - Invalidate the policy cache when a provider is registered or edited - Show a policy refusal as a form-level message rather than marking the password field wrong
- Ask the entitlement read to throw rather than answer "not entitled" on an outage, so a blip cannot drop the requirement and cache that - Keep the membership read's old resilience for paths the requirement allows anyway, and fail closed only on the ones it governs - Say why a verification code was refused instead of calling it invalid - Report the requirement from fresh reads, so the settings surface cannot disagree with what sign-in enforces - Document that social sign-in is refused too, and how an owner without a password gets back in
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 33 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
Summary
Type of Change
Testing
Tested manually.
bun run type-check,bun run lint,bun run check:audits(46 audits),bun run check:api-validation,bun run docs-manifest:check, andbun run check:migrations origin/stagingall pass. New unit tests cover the policy module (endpoint classification, entitlement and provider fallbacks, cache), the session hook enforcement, the API route, and the settings control; 587 tests pass across the touched suites.Checklist