Skip to content

Commit cc1775f

Browse files
Merge pull request #795 from supertokens/multitenancy-dashboard
fix: changes for multitenancy dashboard
2 parents 3e1c0ad + f6afdee commit cc1775f

File tree

17 files changed

+166
-156
lines changed

17 files changed

+166
-156
lines changed

v2/emailpassword/common-customizations/multi-tenancy/multi-app.mdx

+12-5
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ In order to create a new app in the SuperTokens core, you can use the following
3535
<CoreInjector defaultValue="http://localhost:3567" showAppId={false}>
3636

3737
```bash
38-
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/app' \
38+
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/app/v2' \
3939
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
4040
--header 'Content-Type: application/json' \
4141
--data-raw '{
4242
"appId": "app1",
43-
"thirdPartyEnabled": true,
44-
"passwordlessEnabled": true,
45-
"emailPasswordEnabled": true,
43+
"firstFactors": ["emailpassword", "thirdparty", "otp-email", "otp-phone"]
4644
"coreConfig": {...}
4745
}'
4846
```
@@ -52,7 +50,16 @@ curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multite
5250
- The above command will create (or update) an app with the appId of `app1`.
5351
- It will also create a default tenant for this app with the tenant ID of `public` (i.e. the default tenantId)
5452
- You can set various core configs for this app (see the config.yaml / docker env var options for your core). The core configs for a new app will inherit from the the configs provided in the config.yaml / docker env (or our edit config dashboard for managed service).
55-
- By default, all the login methods are enabled for a new app (specifically, the `public` tenant of the new app), but you can pass in `false` to any of the login methods specified above to disable them.
53+
- By default, all the login methods are enabled for a new app (specifically, the `public` tenant of the new app), but you can pass in `firstFactors` input to specifically enable selected login methods.
54+
55+
The built-in Factor IDs that can be used for `firstFactors` are:
56+
- Email password auth: `emailpassword`
57+
- Social login / enterprise SSO auth: `thirdparty`
58+
- Passwordless:
59+
- With email OTP: `otp-email`
60+
- With SMS OTP: `otp-phone`
61+
- With email magic link: `link-email`
62+
- With SMS magic link: `link-phone`
5663

5764
:::important
5865
Even if a login method is enabled for a tenant, you will still require to initialise the right recipe on the backend for sign up / in to be possible with that login method. For example, if for a tenant, you have enabled the passwordless login method, but don't use the passwordless (or a combination recipe that has passwordless) on the backend, then end users will not be able to sign up / in using the passwordless APIs cause those APIs won't be exposed via our backend SDK's middleware.

v2/emailpassword/common-customizations/multi-tenancy/new-tenant-config.mdx

+8-14
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ else:
133133
<CoreInjector defaultValue="http://localhost:3567" showTenantId={false}>
134134

135135
```bash
136-
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/tenant' \
136+
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/tenant/v2' \
137137
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
138138
--header 'Content-Type: application/json' \
139139
--data-raw '{
@@ -286,7 +286,7 @@ else:
286286
<CoreInjector defaultValue="http://localhost:3567" showTenantId={false}>
287287

288288
```bash
289-
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/tenant' \
289+
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/tenant/v2' \
290290
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
291291
--header 'Content-Type: application/json' \
292292
--data-raw '{
@@ -340,9 +340,7 @@ async function getTenant(tenantId: string) {
340340
} else {
341341
let coreConfig = resp.coreConfig;
342342

343-
let isEmailPasswordLoginEnabled = resp.emailPassword.enabled;
344-
let isThirdPartyLoginEnabled = resp.thirdParty.enabled;
345-
let isPasswordlessLoginEnabled = resp.passwordless.enabled;
343+
let firstFactors = resp.firstFactors;
346344

347345
let configuredThirdPartyProviders = resp.thirdParty.providers;
348346
}
@@ -393,6 +391,7 @@ func main() {
393391
}
394392
```
395393

394+
396395
</TabItem>
397396
<TabItem value="python">
398397

@@ -455,14 +454,15 @@ else:
455454
</TabItem>
456455
</PythonSyncAsyncSubTabs>
457456

457+
458458
</TabItem>
459459

460460
<TabItem value="curl">
461461

462462
<CoreInjector defaultValue="http://localhost:3567" showAppId showTenantId={false}>
463463

464464
```bash
465-
curl --location --request GET '^{coreInjector_uri_without_quotes}/customer1/recipe/multitenancy/tenant' \
465+
curl --location --request GET '^{coreInjector_uri_without_quotes}/customer1/recipe/multitenancy/tenant/v2' \
466466
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
467467
--header 'Content-Type: application/json'
468468
```
@@ -482,22 +482,16 @@ Otherwise you will get a `200` status code with the following JSON output:
482482
```json
483483
{
484484
"status": "OK",
485-
"emailPassword": {
486-
"enabled": boolean
487-
},
488485
"thirdParty": {
489-
"enabled": boolean,
490486
"providers": [...]
491487
},
492-
"passwordless": {
493-
"enabled": boolean
494-
},
495488
"coreConfig": {
496489
"email_verification_token_lifetime": 7200000,
497490
"password_reset_token_lifetime": 3600000,
498491
"postgresql_connection_uri": "postgresql://localhost:5432/db2"
499492
},
500-
"tenantId": "customer1"
493+
"tenantId": "customer1",
494+
"firstFactors": ["emailpassword", "thirdparty", "otp-email", "otp-phone"],
501495
}
502496
```
503497

v2/emailpassword/custom-ui/multitenant-login.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ else:
150150
<CoreInjector defaultValue="http://localhost:3567" showTenantId={false}>
151151

152152
```bash
153-
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/tenant' \
153+
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/tenant/v2' \
154154
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
155155
--header 'Content-Type: application/json' \
156156
--data-raw '{

v2/emailpassword/pre-built-ui/multitenant-login.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ else:
147147
<CoreInjector defaultValue="http://localhost:3567" showTenantId={false}>
148148

149149
```bash
150-
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/tenant' \
150+
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/tenant/v2' \
151151
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
152152
--header 'Content-Type: application/json' \
153153
--data-raw '{

v2/mfa/backend-setup.mdx

+2-10
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ import MultiFactorAuth from "supertokens-node/recipe/multifactorauth"
177177

178178
async function createNewTenant() {
179179
let resp = await Multitenancy.createOrUpdateTenant("customer1", {
180-
emailPasswordEnabled: true,
181-
passwordlessEnabled: true,
182180
firstFactors: [MultiFactorAuth.FactorIds.EMAILPASSWORD]
183181
});
184182

@@ -211,13 +209,11 @@ Coming soon. In the meantime, checkout the [legacy method](./legacy-method/how-i
211209
<CoreInjector defaultValue="http://localhost:3567" showAppId={false}>
212210

213211
```bash
214-
curl --location --request PUT '^{coreInjector_uri_without_quotes}/appid-<APP_ID>/recipe/multitenancy/tenant' \
212+
curl --location --request PUT '^{coreInjector_uri_without_quotes}/appid-<APP_ID>/recipe/multitenancy/tenant/v2' \
215213
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
216214
--header 'Content-Type: application/json' \
217215
--data-raw '{
218216
"tenantId": "customer1",
219-
"emailPasswordEnabled": true,
220-
"passwordlessEnabled": true,
221217
"firstFactors": ["emailpassword"]
222218
}'
223219
```
@@ -552,8 +548,6 @@ import MultiFactorAuth from "supertokens-node/recipe/multifactorauth"
552548

553549
async function createNewTenant() {
554550
let resp = await Multitenancy.createOrUpdateTenant("customer1", {
555-
emailPasswordEnabled: true,
556-
passwordlessEnabled: true,
557551
firstFactors: [MultiFactorAuth.FactorIds.EMAILPASSWORD],
558552
requiredSecondaryFactors: [MultiFactorAuth.FactorIds.OTP_EMAIL]
559553
});
@@ -587,13 +581,11 @@ Coming soon. In the meantime, checkout the [legacy method](./legacy-method/how-i
587581
<CoreInjector defaultValue="http://localhost:3567" showAppId={false}>
588582

589583
```bash
590-
curl --location --request PUT '^{coreInjector_uri_without_quotes}/appid-<APP_ID>/recipe/multitenancy/tenant' \
584+
curl --location --request PUT '^{coreInjector_uri_without_quotes}/appid-<APP_ID>/recipe/multitenancy/tenant/v2' \
591585
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
592586
--header 'Content-Type: application/json' \
593587
--data-raw '{
594588
"tenantId": "customer1",
595-
"emailPasswordEnabled": true,
596-
"passwordlessEnabled": true,
597589
"firstFactors": ["emailpassword"],
598590
"requiredSecondaryFactors": ["otp-email"]
599591
}'

v2/multitenancy/list-tenants-and-apps.mdx

+20-21
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@ async function listAllTenants() {
3333
tenants.forEach(tenant => {
3434
let coreConfig = tenant.coreConfig;
3535

36-
let isEmailPasswordLoginEnabled = tenant.emailPassword.enabled;
37-
let isThirdPartyLoginEnabled = tenant.thirdParty.enabled;
38-
let isPasswordlessLoginEnabled = tenant.passwordless.enabled;
36+
let firstFactors = tenant.firstFactors;
3937

4038
let configuredThirdPartyProviders = tenant.thirdParty.providers;
4139
});
4240
}
4341
```
4442

43+
The value of `firstFactors` can be as follows:
44+
45+
- `undefined`: All login methods are enabled in the core, any auth recipe initialised in the backend SDK will work
46+
- `[]` (empty array): No login methods are enabled for the tenant
47+
- a non-empty array: Only the login methods in the array are enabled for the tenant
48+
4549
</TabItem>
4650
<TabItem value="go">
4751

@@ -170,7 +174,7 @@ for tenant in response.tenants:
170174
<CoreInjector defaultValue="http://localhost:3567" showAppId showTenantId={false}>
171175

172176
```bash
173-
curl --location --request GET '^{coreInjector_uri_without_quotes}/recipe/multitenancy/tenant/list' \
177+
curl --location --request GET '^{coreInjector_uri_without_quotes}/recipe/multitenancy/tenant/list/v2' \
174178
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
175179
--header 'Content-Type: application/json'
176180
```
@@ -184,21 +188,22 @@ You will get the following JSON output:
184188
"status": "OK",
185189
"tenants": [{
186190
"tenantId": "customer1",
187-
"emailPassword": {
188-
"enabled": true
189-
},
190191
"thirdParty": {
191-
"enabled": true,
192192
"providers": [...]
193193
},
194-
"passwordless": {
195-
"enabled": true
196-
},
197-
"coreConfig": {...}
194+
"coreConfig": {...},
195+
"firstFactors": [...]
198196
}]
199197
}
200198
```
201199

200+
The value of `firstFactors` can be as follows:
201+
202+
- `undefined`: All login methods are enabled in the core, any auth recipe initialised in the backend SDK will work
203+
- `[]` (empty array): No login methods are enabled for the tenant
204+
- a non-empty array: Only the login methods in the array are enabled for the tenant
205+
206+
202207
</TabItem>
203208

204209
</BackendSDKTabs>
@@ -210,7 +215,7 @@ This can only be done via a cURL command. There is no helper function for this i
210215
<CoreInjector defaultValue="http://localhost:3567" showAppId showTenantId={false} showAppId={false}>
211216

212217
```bash
213-
curl --location --request GET '^{coreInjector_uri_without_quotes}/recipe/multitenancy/app/list' \
218+
curl --location --request GET '^{coreInjector_uri_without_quotes}/recipe/multitenancy/app/list/v2' \
214219
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
215220
--header 'Content-Type: application/json'
216221
```
@@ -226,17 +231,11 @@ You will get the following JSON output:
226231
"appId": "app1",
227232
"tenants": [{
228233
"tenantId": "customer1",
229-
"emailPassword": {
230-
"enabled": true
231-
},
232234
"thirdParty": {
233-
"enabled": true,
234235
"providers": [...]
235236
},
236-
"passwordless": {
237-
"enabled": true
238-
},
239-
"coreConfig": {...}
237+
"coreConfig": {...},
238+
"firstFactors": [...]
240239
}]
241240
}]
242241
}

v2/multitenancy/new-app.mdx

+12-5
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ In order to create a new app in the SuperTokens core, you can use the following
3434
<CoreInjector defaultValue="http://localhost:3567" showAppId={false}>
3535

3636
```bash
37-
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/app' \
37+
curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multitenancy/app/v2' \
3838
--header 'api-key: ^{coreInjector_api_key_without_quotes}' \
3939
--header 'Content-Type: application/json' \
4040
--data-raw '{
4141
"appId": "app1",
42-
"thirdPartyEnabled": true,
43-
"passwordlessEnabled": true,
44-
"emailPasswordEnabled": true,
42+
"firstFactors": ["emailpassword", "thirdparty", "otp-email", "otp-phone"]
4543
"coreConfig": {...}
4644
}'
4745
```
@@ -51,7 +49,16 @@ curl --location --request PUT '^{coreInjector_uri_without_quotes}/recipe/multite
5149
- The above command will create (or update) an app with the appId of `app1`.
5250
- It will also create a default tenant for this app with the tenant ID of `public` (i.e. the default tenantId)
5351
- You can set various core configs for this app (see the config.yaml / docker env var options for your core). The core configs for a new app will inherit from the the configs provided in the config.yaml / docker env (or our edit config dashboard for managed service).
54-
- By default, all the login methods are enabled for a new app (specifically, the `public` tenant of the new app), but you can pass in `false` to any of the login methods specified above to disable them.
52+
- By default, all the login methods are enabled for a new app (specifically, the `public` tenant of the new app), but you can pass in `firstFactors` input to specifically enable selected login methods.
53+
54+
The built-in Factor IDs that can be used for `firstFactors` are:
55+
- Email password auth: `emailpassword`
56+
- Social login / enterprise SSO auth: `thirdparty`
57+
- Passwordless:
58+
- With email OTP: `otp-email`
59+
- With SMS OTP: `otp-phone`
60+
- With email magic link: `link-email`
61+
- With SMS magic link: `link-phone`
5562

5663
:::important
5764
Even if a login method is enabled for a tenant, you will still require to initialise the right recipe on the backend for sign up / in to be possible with that login method. For example, if for a tenant, you have enabled the passwordless login method, but don't use the passwordless (or a combination recipe that has passwordless) on the backend, then end users will not be able to sign up / in using the passwordless APIs cause those APIs won't be exposed via our backend SDK's middleware.

0 commit comments

Comments
 (0)