Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -614,21 +614,34 @@ You can create, update, delete or load tenants, as well as read and update tenan
```typescript
// The self provisioning domains or optional. If given they'll be used to associate
// Users logging in to this tenant
await descopeClient.management.tenant.create('My Tenant', ['domain.com'], {
customAttributeName: 'val',
});
await descopeClient.management.tenant.create(
'My Tenant',
['domain.com'],
{ customAttributeName: 'val' },
true, // enforceSSO
false, // disabled
'', // parent tenant ID
'none', // roleInheritance
['admin@domain.com'], // enforceSSOExclusions - user IDs excluded from SSO enforcement
Comment thread
hagaikali marked this conversation as resolved.
Outdated
);

// You can optionally set your own ID when creating a tenant
await descopeClient.management.tenant.createWithId('my-custom-id', 'My Tenant', ['domain.com'], {
Comment thread
hagaikali marked this conversation as resolved.
Outdated
customAttributeName: 'val',
});

// Update will override all fields as is. Use carefully.
// Any field you omit is cleared on the tenant, so read the tenant first and pass
Comment thread
hagaikali marked this conversation as resolved.
Outdated
// back the values you want to keep.
await descopeClient.management.tenant.update(
'my-custom-id',
'My Tenant',
['domain.com', 'another-domain.com'],
{ customAttributeName: 'val' },
true, // enforceSSO
Comment thread
hagaikali marked this conversation as resolved.
false, // disabled
'none', // roleInheritance
['admin@domain.com'], // enforceSSOExclusions - user IDs excluded from SSO enforcement
);

// Update the tenant's default roles by providing role names.
Expand Down
6 changes: 6 additions & 0 deletions lib/management/tenant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ describe('Management Tenant', () => {
true,
'p',
'none',
['excluded@example.com'],
);

expect(mockHttpClient.post).toHaveBeenCalledWith(apiPaths.tenant.create, {
name: 'name',
selfProvisioningDomains: ['d1'],
customAttributes: { customAttr: 'value' },
enforceSSO: true,
enforceSSOExclusions: ['excluded@example.com'],
disabled: true,
parent: 'p',
roleInheritance: 'none',
Expand Down Expand Up @@ -146,6 +148,7 @@ describe('Management Tenant', () => {
true,
'p',
'',
['excluded@example.com'],
);

expect(mockHttpClient.post).toHaveBeenCalledWith(apiPaths.tenant.create, {
Expand All @@ -154,6 +157,7 @@ describe('Management Tenant', () => {
selfProvisioningDomains: ['d1'],
customAttributes: { customAttr: 'value' },
enforceSSO: true,
enforceSSOExclusions: ['excluded@example.com'],
disabled: true,
parent: 'p',
roleInheritance: '',
Expand Down Expand Up @@ -227,6 +231,7 @@ describe('Management Tenant', () => {
true,
true,
'none',
['excluded@example.com'],
);

expect(mockHttpClient.post).toHaveBeenCalledWith(apiPaths.tenant.update, {
Expand All @@ -235,6 +240,7 @@ describe('Management Tenant', () => {
selfProvisioningDomains: ['d1'],
customAttributes: { customAttr: 'value' },
enforceSSO: true,
enforceSSOExclusions: ['excluded@example.com'],
disabled: true,
roleInheritance: 'none',
});
Expand Down
6 changes: 6 additions & 0 deletions lib/management/tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ const withTenant = (httpClient: HttpClient) => ({
disabled?: boolean,
parent?: string,
roleInheritance?: '' | 'none' | 'userOnly',
enforceSSOExclusions?: string[],
): Promise<SdkResponse<CreateTenantResponse>> =>
transformResponse(
httpClient.post(apiPaths.tenant.create, {
name,
selfProvisioningDomains,
customAttributes,
enforceSSO,
enforceSSOExclusions,
disabled,
parent,
roleInheritance,
Expand All @@ -42,6 +44,7 @@ const withTenant = (httpClient: HttpClient) => ({
disabled?: boolean,
parent?: string,
roleInheritance?: '' | 'none' | 'userOnly',
enforceSSOExclusions?: string[],
): Promise<SdkResponse<never>> =>
transformResponse(
httpClient.post(apiPaths.tenant.create, {
Expand All @@ -50,6 +53,7 @@ const withTenant = (httpClient: HttpClient) => ({
selfProvisioningDomains,
customAttributes,
enforceSSO,
enforceSSOExclusions,
disabled,
parent,
roleInheritance,
Expand All @@ -63,6 +67,7 @@ const withTenant = (httpClient: HttpClient) => ({
enforceSSO?: boolean,
disabled?: boolean,
roleInheritance?: '' | 'none' | 'userOnly',
enforceSSOExclusions?: string[],
): Promise<SdkResponse<never>> =>
transformResponse(
httpClient.post(apiPaths.tenant.update, {
Expand All @@ -71,6 +76,7 @@ const withTenant = (httpClient: HttpClient) => ({
selfProvisioningDomains,
customAttributes,
enforceSSO,
enforceSSOExclusions,
disabled,
roleInheritance,
}),
Expand Down
2 changes: 2 additions & 0 deletions lib/management/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ export type Tenant = {
domains?: string[];
authType?: 'none' | 'saml' | 'oidc';
enforceSSO?: boolean;
enforceSSOExclusions?: string[];
disabled?: boolean;
defaultRoles?: string[];
roleInheritance?: '' | 'none' | 'userOnly';
};

export type SSOSetupSuiteSettingsDisabledFeatures = {
Expand Down