Repository navigation
feat(clerk-js,ui): gate self-serve Directory Sync on its own organization flag #10374
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
Merged
kalafut
merged 2 commits into
main
from
jim/orgs-1953-self-serve-directory-sync-org-flag
Oct 23, 2026
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| '@clerk/shared': minor | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/ui': minor | ||
| '@clerk/mosaic': patch | ||
| --- | ||
|
|
||
| Add `selfServeDirectorySyncEnabled` to `OrganizationResource`. Self-serve Directory Sync is now enabled per organization by this setting instead of following `selfServeSSOEnabled`. In `<OrganizationProfile />`, the Security page now appears for organizations that have only Directory Sync enabled, and their admins can manage the connection's directory. Organizations that have self-serve SSO without Directory Sync no longer see the Directory Sync section. | ||
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
76 changes: 76 additions & 0 deletions
76
packages/shared/src/internal/clerk-js/__tests__/componentGuards.test.ts
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,76 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import type { Clerk, EnvironmentResource } from '@/types'; | ||
|
|
||
| import { disabledSelfServeDirectorySyncFeature, disabledSelfServeSSOFeature } from '../componentGuards'; | ||
|
|
||
| type Flags = { | ||
| selfServeSSO?: boolean; | ||
| selfServeDirectorySync?: boolean; | ||
| orgSSO?: boolean; | ||
| orgDirectorySync?: boolean; | ||
| }; | ||
|
|
||
| const setup = ({ | ||
| selfServeSSO = true, | ||
| selfServeDirectorySync = true, | ||
| orgSSO = false, | ||
| orgDirectorySync = false, | ||
| }: Flags) => { | ||
| const clerk = { | ||
| organization: { selfServeSSOEnabled: orgSSO, selfServeDirectorySyncEnabled: orgDirectorySync }, | ||
| } as unknown as Clerk; | ||
| const environment = { | ||
| userSettings: { | ||
| enterpriseSSO: { | ||
| enabled: true, | ||
| self_serve_sso: selfServeSSO, | ||
| self_serve_directory_sync: selfServeDirectorySync, | ||
| }, | ||
| }, | ||
| } as unknown as EnvironmentResource; | ||
| return [clerk, environment] as const; | ||
| }; | ||
|
|
||
| describe('disabledSelfServeSSOFeature', () => { | ||
| it('is enabled when the instance and the organization allow self-serve SSO', () => { | ||
| expect(disabledSelfServeSSOFeature(...setup({ orgSSO: true }))).toBe(false); | ||
| }); | ||
|
|
||
| it('is disabled when the organization does not allow self-serve SSO', () => { | ||
| expect(disabledSelfServeSSOFeature(...setup({ orgSSO: false, orgDirectorySync: true }))).toBe(true); | ||
| }); | ||
|
|
||
| it('is disabled when the instance does not allow self-serve SSO', () => { | ||
| expect(disabledSelfServeSSOFeature(...setup({ selfServeSSO: false, orgSSO: true }))).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('disabledSelfServeDirectorySyncFeature', () => { | ||
| it('is enabled when the organization allows Directory Sync, even without self-serve SSO', () => { | ||
| expect(disabledSelfServeDirectorySyncFeature(...setup({ orgSSO: false, orgDirectorySync: true }))).toBe(false); | ||
| }); | ||
|
|
||
| it('is enabled when the organization allows both SSO and Directory Sync', () => { | ||
| expect(disabledSelfServeDirectorySyncFeature(...setup({ orgSSO: true, orgDirectorySync: true }))).toBe(false); | ||
| }); | ||
|
|
||
| it('is disabled when the organization allows SSO but not Directory Sync', () => { | ||
| expect(disabledSelfServeDirectorySyncFeature(...setup({ orgSSO: true, orgDirectorySync: false }))).toBe(true); | ||
| }); | ||
|
|
||
| it('is disabled when the instance does not allow self-serve SSO', () => { | ||
| expect(disabledSelfServeDirectorySyncFeature(...setup({ selfServeSSO: false, orgDirectorySync: true }))).toBe(true); | ||
| }); | ||
|
|
||
| it('is disabled when the instance does not allow self-serve Directory Sync', () => { | ||
| expect( | ||
| disabledSelfServeDirectorySyncFeature(...setup({ selfServeDirectorySync: false, orgDirectorySync: true })), | ||
| ).toBe(true); | ||
| }); | ||
|
|
||
| it('is disabled without an active organization', () => { | ||
| const [, environment] = setup({}); | ||
| expect(disabledSelfServeDirectorySyncFeature({ organization: null } as unknown as Clerk, environment)).toBe(true); | ||
| }); | ||
| }); |
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.
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: clerk/javascript
Length of output: 1308
🏁 Script executed:
Repository: clerk/clerk-docs
Length of output: 44688
🏁 Script executed:
Repository: clerk/javascript
Length of output: 14349
Update the public Directory Sync documentation.
The Directory Sync guide still says that self-serve SSO enables Directory Sync and that there is no separate setting. The
OrganizationProfilereference still describes self-serve SSO as the condition for its Security tab, while omitting Directory-Sync-only organizations.Update both pages to document
selfServeDirectorySyncEnabledand Directory-Sync-only organizations. Preserve the separate requirement for an SSO connection where applicable; the organization-level self-serve SSO flag is no longer required for Directory Sync.🧰 Tools
🪛 markdownlint-cli2 (0.23.3)
[warning] 8-8: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
🤖 Prompt for AI Agents