Skip to content

Commit d00e41c

Browse files
committed
Add self_serve_sso_enabled to Organization
1 parent 0519955 commit d00e41c

16 files changed

Lines changed: 69 additions & 34 deletions

File tree

packages/backend/src/api/resources/JSON.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ export interface OrganizationJSON extends ClerkResourceJSON {
375375
pending_invitations_count?: number;
376376
max_allowed_memberships: number;
377377
admin_delete_enabled: boolean;
378+
self_serve_sso_enabled?: boolean;
378379
public_metadata: OrganizationPublicMetadata | null;
379380
private_metadata?: OrganizationPrivateMetadata;
380381
created_by?: string;

packages/backend/src/api/resources/Organization.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class Organization {
6363
* The ID of the user who created the Organization.
6464
*/
6565
readonly createdBy?: string,
66+
readonly selfServeSSOEnabled?: boolean,
6667
) {}
6768

6869
static fromJSON(data: OrganizationJSON): Organization {
@@ -80,6 +81,7 @@ export class Organization {
8081
data.admin_delete_enabled,
8182
data.members_count,
8283
data.created_by,
84+
data.self_serve_sso_enabled,
8385
);
8486
res._raw = data;
8587
return res;

packages/clerk-js/src/core/resources/Organization.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class Organization extends BaseResource implements OrganizationResource {
4949
membersCount = 0;
5050
pendingInvitationsCount = 0;
5151
maxAllowedMemberships!: number;
52+
selfServeSSOEnabled = false;
5253

5354
constructor(data: OrganizationJSON | OrganizationJSONSnapshot) {
5455
super();
@@ -303,6 +304,7 @@ export class Organization extends BaseResource implements OrganizationResource {
303304
this.pendingInvitationsCount = data.pending_invitations_count || 0;
304305
this.maxAllowedMemberships = data.max_allowed_memberships || 0;
305306
this.adminDeleteEnabled = data.admin_delete_enabled || false;
307+
this.selfServeSSOEnabled = data.self_serve_sso_enabled || false;
306308
this.createdAt = unixEpochToDate(data.created_at);
307309
this.updatedAt = unixEpochToDate(data.updated_at);
308310
return this;
@@ -321,6 +323,7 @@ export class Organization extends BaseResource implements OrganizationResource {
321323
pending_invitations_count: this.pendingInvitationsCount,
322324
max_allowed_memberships: this.maxAllowedMemberships,
323325
admin_delete_enabled: this.adminDeleteEnabled,
326+
self_serve_sso_enabled: this.selfServeSSOEnabled,
324327
created_at: this.createdAt.getTime(),
325328
updated_at: this.updatedAt.getTime(),
326329
};

packages/clerk-js/src/core/resources/__tests__/Organization.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('Organization', () => {
1919
admin_delete_enabled: true,
2020
max_allowed_memberships: 3,
2121
has_image: true,
22+
self_serve_sso_enabled: true,
2223
});
2324

2425
expect(organization).toMatchObject({
@@ -32,11 +33,32 @@ describe('Organization', () => {
3233
pendingInvitationsCount: 10,
3334
maxAllowedMemberships: 3,
3435
adminDeleteEnabled: true,
36+
selfServeSSOEnabled: true,
3537
createdAt: expect.any(Date),
3638
updatedAt: expect.any(Date),
3739
publicMetadata: {
3840
public: 'metadata',
3941
},
4042
});
4143
});
44+
45+
it('defaults selfServeSSOEnabled to false when the field is omitted from FAPI', () => {
46+
const organization = new Organization({
47+
object: 'organization',
48+
id: 'test_id',
49+
name: 'test_name',
50+
public_metadata: {},
51+
slug: 'test_slug',
52+
image_url: '',
53+
created_at: 12345,
54+
updated_at: 5678,
55+
members_count: 1,
56+
pending_invitations_count: 0,
57+
admin_delete_enabled: true,
58+
max_allowed_memberships: 3,
59+
has_image: false,
60+
});
61+
62+
expect(organization.selfServeSSOEnabled).toBe(false);
63+
});
4264
});

packages/localizations/src/en-US.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ export const enUS: LocalizationResource = {
768768
navbar: {
769769
apiKeys: 'API keys',
770770
billing: 'Billing',
771-
selfServeSso: 'Self-Serve SSO',
771+
selfServeSSO: 'Single Sign-On (SSO)',
772772
description: 'Manage your organization.',
773773
general: 'General',
774774
members: 'Members',

packages/shared/src/types/json.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ export interface OrganizationJSON extends ClerkResourceJSON {
393393
pending_invitations_count: number;
394394
admin_delete_enabled: boolean;
395395
max_allowed_memberships: number;
396+
self_serve_sso_enabled?: boolean;
396397
}
397398

398399
export interface OrganizationMembershipJSON extends ClerkResourceJSON {

packages/shared/src/types/localization.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ export type __internal_LocalizationResource = {
10211021
members: LocalizationValue;
10221022
billing: LocalizationValue;
10231023
apiKeys: LocalizationValue;
1024-
selfServeSso: LocalizationValue;
1024+
selfServeSSO: LocalizationValue;
10251025
};
10261026
badge__unverified: LocalizationValue;
10271027
badge__automaticInvitation: LocalizationValue;

packages/shared/src/types/organization.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ export interface OrganizationResource extends ClerkResource, BillingPayerMethods
4646
publicMetadata: OrganizationPublicMetadata;
4747
adminDeleteEnabled: boolean;
4848
maxAllowedMemberships: number;
49+
/**
50+
* Whether the organization opted-in to self-serve SSO. Defaults to `false`
51+
* when the instance does not have self-serve SSO enabled.
52+
*/
53+
selfServeSSOEnabled: boolean;
4954
createdAt: Date;
5055
updatedAt: Date;
5156
update: (params: UpdateOrganizationParams) => Promise<OrganizationResource>;

packages/ui/src/components/ConfigureSSO/__tests__/ConfigureSSO.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('ConfigureSSO', () => {
1111
describe('within an organization', () => {
1212
it('shows a warning if the active organization membership lacks the manage enterprise connections permission', async () => {
1313
const { wrapper, fixtures } = await createFixtures(f => {
14-
f.withEnterpriseSso({ selfServeSso: true });
14+
f.withEnterpriseSso({ selfServeSSO: true });
1515
f.withEmailAddress();
1616
f.withOrganizations();
1717
f.withUser({
@@ -31,7 +31,7 @@ describe('ConfigureSSO', () => {
3131

3232
it('renders the wizard when the active organization membership has the manage enterprise connections permission', async () => {
3333
const { wrapper, fixtures } = await createFixtures(f => {
34-
f.withEnterpriseSso({ selfServeSso: true });
34+
f.withEnterpriseSso({ selfServeSSO: true });
3535
f.withEmailAddress();
3636
f.withOrganizations();
3737
f.withUser({
@@ -54,7 +54,7 @@ describe('ConfigureSSO', () => {
5454
describe('in a personal workspace', () => {
5555
it('renders the wizard without checking the manage enterprise connections permission', async () => {
5656
const { wrapper, fixtures } = await createFixtures(f => {
57-
f.withEnterpriseSso({ selfServeSso: true });
57+
f.withEnterpriseSso({ selfServeSSO: true });
5858
f.withEmailAddress();
5959
f.withUser({ email_addresses: ['test@clerk.com'] });
6060
});

packages/ui/src/components/OrganizationProfile/OrganizationProfileRoutes.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ const OrganizationPaymentAttemptPage = lazy(() =>
3737
})),
3838
);
3939

40-
const OrganizationSelfServeSsoPage = lazy(() =>
41-
import(/* webpackChunkName: "op-self-serve-sso-page"*/ './OrganizationSelfServeSsoPage').then(module => ({
42-
default: module.OrganizationSelfServeSsoPage,
40+
const OrganizationSelfServeSSOPage = lazy(() =>
41+
import(/* webpackChunkName: "op-self-serve-sso-page"*/ './OrganizationSelfServeSSOPage').then(module => ({
42+
default: module.OrganizationSelfServeSSOPage,
4343
})),
4444
);
4545

@@ -52,7 +52,7 @@ export const OrganizationProfileRoutes = () => {
5252
isAPIKeysPageRoot,
5353
isSelfServeSsoPageRoot,
5454
shouldShowBilling,
55-
shouldShowSelfServeSso,
55+
shouldShowSelfServeSSO,
5656
apiKeysProps,
5757
} = useOrganizationProfileContext();
5858

@@ -150,11 +150,11 @@ export const OrganizationProfileRoutes = () => {
150150
</Route>
151151
</Protect>
152152
)}
153-
{shouldShowSelfServeSso ? (
153+
{shouldShowSelfServeSSO ? (
154154
<Route path={isSelfServeSsoPageRoot ? undefined : 'organization-self-serve-sso'}>
155155
<Switch>
156156
<Route index>
157-
<OrganizationSelfServeSsoPage />
157+
<OrganizationSelfServeSSOPage />
158158
</Route>
159159
</Switch>
160160
</Route>

0 commit comments

Comments
 (0)