-
Notifications
You must be signed in to change notification settings - Fork 452
feat(ui): Self-serve SSO within OrganizationProfile
#8600
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7e79427
Render route in OrganizationProfile
LauraBeatris 362f611
Render `ConfigureSSO` content within `OrganizationProfile`
LauraBeatris 3562d52
Add `self_serve_sso_enabled` to `Organization`
LauraBeatris 9772afb
Add changeset
LauraBeatris 6e345b0
Add protect as children of content
LauraBeatris 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/localizations': minor | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/shared': minor | ||
| '@clerk/ui': minor | ||
| --- | ||
|
|
||
| Display "Single Sign-on (SSO)" section in `OrganizationProfile` if self-serve SSO is enabled on the current active organization |
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
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 |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ describe('ConfigureSSO', () => { | |
| describe('within an organization', () => { | ||
| it('shows a warning if the active organization membership lacks the manage enterprise connections permission', async () => { | ||
| const { wrapper, fixtures } = await createFixtures(f => { | ||
| f.withEnterpriseSso({ selfServeSso: true }); | ||
| f.withEnterpriseSso({ selfServeSSO: true }); | ||
| f.withEmailAddress(); | ||
| f.withOrganizations(); | ||
| f.withUser({ | ||
|
|
@@ -31,7 +31,7 @@ describe('ConfigureSSO', () => { | |
|
|
||
| it('renders the wizard when the active organization membership has the manage enterprise connections permission', async () => { | ||
| const { wrapper, fixtures } = await createFixtures(f => { | ||
| f.withEnterpriseSso({ selfServeSso: true }); | ||
| f.withEnterpriseSso({ selfServeSSO: true }); | ||
| f.withEmailAddress(); | ||
| f.withOrganizations(); | ||
| f.withUser({ | ||
|
|
@@ -54,7 +54,7 @@ describe('ConfigureSSO', () => { | |
| describe('in a personal workspace', () => { | ||
| it('renders the wizard without checking the manage enterprise connections permission', async () => { | ||
| const { wrapper, fixtures } = await createFixtures(f => { | ||
| f.withEnterpriseSso({ selfServeSso: true }); | ||
| f.withEnterpriseSso({ selfServeSSO: true }); | ||
| f.withEmailAddress(); | ||
| f.withUser({ email_addresses: ['[email protected]'] }); | ||
| }); | ||
|
|
||
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
16 changes: 16 additions & 0 deletions
16
packages/ui/src/components/OrganizationProfile/OrganizationSelfServeSSOPage.tsx
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,16 @@ | ||
| import { useOrganization } from '@clerk/shared/react'; | ||
| import { useRef } from 'react'; | ||
|
|
||
| import { ConfigureSSOContent } from '../ConfigureSSO/ConfigureSSO'; | ||
|
|
||
| export const OrganizationSelfServeSSOPage = () => { | ||
| const { organization } = useOrganization(); | ||
| const contentRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| if (!organization) { | ||
| // We should never reach this point, but we'll return null to make TS happy | ||
| return null; | ||
| } | ||
|
|
||
| return <ConfigureSSOContent contentRef={contentRef} />; | ||
| }; |
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 |
|---|---|---|
|
|
@@ -2,9 +2,10 @@ import type { CustomPage } from '@clerk/shared/types'; | |
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { bindCreateFixtures } from '@/test/create-fixtures'; | ||
| import { render, screen, waitFor } from '@/test/utils'; | ||
| import { cleanup, render, screen, waitFor } from '@/test/utils'; | ||
|
|
||
| import { OrganizationProfile } from '../'; | ||
| import { OrganizationSelfServeSSOPage } from '../OrganizationSelfServeSSOPage'; | ||
|
|
||
| const { createFixtures } = bindCreateFixtures('OrganizationProfile'); | ||
|
|
||
|
|
@@ -476,6 +477,97 @@ describe('OrganizationProfile', () => { | |
| }); | ||
| }); | ||
|
|
||
| describe('SSO visibility', () => { | ||
| it('includes SSO when enabled at the instance and the org has opted in', async () => { | ||
| const { wrapper } = await createFixtures(f => { | ||
| f.withEnterpriseSso({ selfServeSSO: true }); | ||
| f.withOrganizations(); | ||
| f.withUser({ | ||
| email_addresses: ['[email protected]'], | ||
| organization_memberships: [ | ||
| { | ||
| name: 'Org1', | ||
| self_serve_sso_enabled: true, | ||
| permissions: ['org:sys_entconns:manage'], | ||
| }, | ||
| ], | ||
| }); | ||
| }); | ||
|
|
||
| render(<OrganizationProfile />, { wrapper }); | ||
| expect(await screen.findByText('Single Sign-On (SSO)')).toBeDefined(); | ||
| }); | ||
|
|
||
| it('does not include SSO when disabled at the instance level', async () => { | ||
| const { wrapper } = await createFixtures(f => { | ||
| f.withEnterpriseSso({ selfServeSSO: false }); | ||
| f.withOrganizations(); | ||
| f.withUser({ | ||
| email_addresses: ['[email protected]'], | ||
| organization_memberships: [ | ||
| { | ||
| name: 'Org1', | ||
| self_serve_sso_enabled: true, | ||
| permissions: ['org:sys_entconns:manage'], | ||
| }, | ||
| ], | ||
| }); | ||
| }); | ||
|
|
||
| const { queryByText } = render(<OrganizationProfile />, { wrapper }); | ||
| await waitFor(() => expect(queryByText('Single Sign-On (SSO)')).toBeNull()); | ||
| }); | ||
|
|
||
| it('does not include SSO when the org has not opted in, even if the instance has it enabled', async () => { | ||
| const { wrapper } = await createFixtures(f => { | ||
| f.withEnterpriseSso({ selfServeSSO: true }); | ||
| f.withOrganizations(); | ||
| f.withUser({ | ||
| email_addresses: ['[email protected]'], | ||
| organization_memberships: [ | ||
| { | ||
| name: 'Org1', | ||
| self_serve_sso_enabled: false, | ||
| permissions: ['org:sys_entconns:manage'], | ||
| }, | ||
| ], | ||
| }); | ||
| }); | ||
|
|
||
| const { queryByText } = render(<OrganizationProfile />, { wrapper }); | ||
| await waitFor(() => expect(queryByText('Single Sign-On (SSO)')).toBeNull()); | ||
| }); | ||
|
|
||
| it('includes SSO even when the user does not have the manage enterprise connections permission, but the page surfaces a warning', async () => { | ||
| const { wrapper, fixtures } = await createFixtures(f => { | ||
| f.withEnterpriseSso({ selfServeSSO: true }); | ||
| f.withOrganizations(); | ||
| f.withUser({ | ||
| email_addresses: ['[email protected]'], | ||
| organization_memberships: [ | ||
| { | ||
| name: 'Org1', | ||
| self_serve_sso_enabled: true, | ||
| permissions: [], | ||
| }, | ||
| ], | ||
| }); | ||
| }); | ||
|
|
||
| fixtures.clerk.user?.getEnterpriseConnections.mockResolvedValue([]); | ||
|
|
||
| render(<OrganizationProfile />, { wrapper }); | ||
| expect(await screen.findByText('Single Sign-On (SSO)')).toBeDefined(); | ||
|
|
||
| cleanup(); | ||
| render(<OrganizationSelfServeSSOPage />, { wrapper }); | ||
| expect(await screen.findByText(/you do not have permission to manage single sign-on/i)).toBeDefined(); | ||
| expect( | ||
| screen.queryByText(/contact your organization.*administrator to upgrade your permissions/i), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| it('removes member nav item if user is lacking permissions', async () => { | ||
| const { wrapper } = await createFixtures(f => { | ||
| f.withOrganizations(); | ||
|
|
||
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.