Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/dull-plums-sleep.md
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
6 changes: 6 additions & 0 deletions .changeset/tangy-jeans-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/clerk-js': patch
'@clerk/shared': patch
---

Guard `ConfigureSSO` based on active organization
33 changes: 24 additions & 9 deletions packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1462,28 +1462,43 @@ export class Clerk implements ClerkInterface {
* @param props Configuration parameters.
*/
public mountConfigureSSO = (node: HTMLDivElement, props?: ConfigureSSOProps) => {
if (disabledSelfServeSSOFeature(this, this.environment)) {
const { isEnabled: isOrganizationsEnabled } = this.__internal_attemptToEnableEnvironmentSetting({
for: 'organizations',
caller: 'ConfigureSSO',
onClose: () => {
throw new ClerkRuntimeError(warnings.cannotRenderAnyOrganizationComponent('ConfigureSSO'), {
code: CANNOT_RENDER_ORGANIZATIONS_DISABLED_ERROR_CODE,
});
},
});

if (!isOrganizationsEnabled) {
return;
}

const userExists = !noUserExists(this);
if (noOrganizationExists(this) && userExists) {
if (this.#instanceType === 'development') {
throw new ClerkRuntimeError(warnings.cannotRenderConfigureSSOComponentWhenDisabled, {
code: CANNOT_RENDER_SELF_SERVE_SSO_DISABLED_ERROR_CODE,
throw new ClerkRuntimeError(warnings.cannotRenderComponentWhenOrgDoesNotExist, {
code: CANNOT_RENDER_ORGANIZATION_MISSING_ERROR_CODE,
});
}
return;
}

if (disabledEmailAddressAttribute(this, this.environment)) {
if (disabledSelfServeSSOFeature(this, this.environment)) {
if (this.#instanceType === 'development') {
throw new ClerkRuntimeError(warnings.cannotRenderConfigureSSOComponentWhenEmailAddressDisabled, {
code: CANNOT_RENDER_CONFIGURE_SSO_EMAIL_ADDRESS_DISABLED_ERROR_CODE,
throw new ClerkRuntimeError(warnings.cannotRenderConfigureSSOComponentWhenDisabled, {
code: CANNOT_RENDER_SELF_SERVE_SSO_DISABLED_ERROR_CODE,
});
}
return;
}

if (noUserExists(this)) {
if (disabledEmailAddressAttribute(this, this.environment)) {
if (this.#instanceType === 'development') {
throw new ClerkRuntimeError(warnings.cannotRenderConfigureSSOComponentWhenUserDoesNotExist, {
code: CANNOT_RENDER_USER_MISSING_ERROR_CODE,
throw new ClerkRuntimeError(warnings.cannotRenderConfigureSSOComponentWhenEmailAddressDisabled, {
code: CANNOT_RENDER_CONFIGURE_SSO_EMAIL_ADDRESS_DISABLED_ERROR_CODE,
});
}
return;
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/internal/clerk-js/componentGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export const disabledAllAPIKeysFeatures: ComponentGuard = (_, environment) => {
return disabledUserAPIKeysFeature(_, environment) && disabledOrganizationAPIKeysFeature(_, environment);
};

export const disabledSelfServeSSOFeature: ComponentGuard = (_, environment) => {
return !environment?.userSettings.enterpriseSSO.self_serve_sso;
export const disabledSelfServeSSOFeature: ComponentGuard = (clerk, environment) => {
return !environment?.userSettings.enterpriseSSO.self_serve_sso || !clerk.organization?.selfServeSSOEnabled;
};

export const disabledEmailAddressAttribute: ComponentGuard = (_, environment) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/src/internal/clerk-js/warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const createMessageForDisabledOrganizations = (
| 'OrganizationSwitcher'
| 'OrganizationList'
| 'CreateOrganization'
| 'TaskChooseOrganization',
| 'TaskChooseOrganization'
| 'ConfigureSSO',
) => {
return formatWarning(
`The <${componentName}/> cannot be rendered when the feature is turned off. Visit 'dashboard.clerk.com' to enable the feature. Since the feature is turned off, this is no-op.`,
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/types/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,7 @@ export type __internal_AttemptToEnableEnvironmentSettingParams = {
| 'OrganizationList'
| 'CreateOrganization'
| 'TaskChooseOrganization'
| 'ConfigureSSO'
| 'useOrganizationList'
| 'useOrganization';
onClose?: () => void;
Expand Down
Loading