@logto/schemas 1.16.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/alterations/1.17.0-1715826336-add-default-user-role-config.ts +18 -0
- package/alterations/1.17.0-1715829731-rename-data-hook-schema-update-event.ts +120 -0
- package/alterations/1.17.0-1716278409-remove-internal-role-database-policies.ts +37 -0
- package/alterations/1.17.0-1716291265-create-pre-configured-m-api-role.ts +92 -0
- package/alterations/1.17.0-1717148078-remove-service-log-reference.ts +19 -0
- package/alterations/1.18.0-1717567857-social-sign-in-linking.ts +18 -0
- package/alterations/1.18.0-1717597875-add-organization-email-domains-table.ts +31 -0
- package/alterations/1.18.0-1717818597-organization-mfa-requirement.ts +18 -0
- package/alterations/1.18.0-1718340884-rename-org-email-domains-and-add-jit-roles-table.ts +56 -0
- package/alterations/1.18.0-1718594164-add-agree-to-terms-policy.ts +40 -0
- package/alterations/1.18.0-1718785576-organization-application-relations.ts +37 -0
- package/alterations/1.18.0-1718786576-organization-jit-sso-connectors.ts +31 -0
- package/alterations/1.18.0-1718807616-organization-role-application-relations.ts +34 -0
- package/alterations/1.18.0-1718865814-add-subject-tokens.ts +36 -0
- package/alterations/1.18.0-1719014832-organization-role-types.ts +35 -0
- package/alterations/1.18.0-1719221205-fix-functions.ts +25 -0
- package/alterations/1.18.0-1719312694-custom-ui-assets.ts +18 -0
- package/alterations/utils/1716643968-id-generation.ts +46 -0
- package/alterations-js/1.17.0-1715826336-add-default-user-role-config.d.ts +3 -0
- package/alterations-js/1.17.0-1715826336-add-default-user-role-config.js +14 -0
- package/alterations-js/1.17.0-1715829731-rename-data-hook-schema-update-event.d.ts +3 -0
- package/alterations-js/1.17.0-1715829731-rename-data-hook-schema-update-event.js +96 -0
- package/alterations-js/1.17.0-1716278409-remove-internal-role-database-policies.d.ts +3 -0
- package/alterations-js/1.17.0-1716278409-remove-internal-role-database-policies.js +33 -0
- package/alterations-js/1.17.0-1716291265-create-pre-configured-m-api-role.d.ts +7 -0
- package/alterations-js/1.17.0-1716291265-create-pre-configured-m-api-role.js +77 -0
- package/alterations-js/1.17.0-1717148078-remove-service-log-reference.d.ts +3 -0
- package/alterations-js/1.17.0-1717148078-remove-service-log-reference.js +15 -0
- package/alterations-js/1.18.0-1717567857-social-sign-in-linking.d.ts +3 -0
- package/alterations-js/1.18.0-1717567857-social-sign-in-linking.js +14 -0
- package/alterations-js/1.18.0-1717597875-add-organization-email-domains-table.d.ts +3 -0
- package/alterations-js/1.18.0-1717597875-add-organization-email-domains-table.js +26 -0
- package/alterations-js/1.18.0-1717818597-organization-mfa-requirement.d.ts +3 -0
- package/alterations-js/1.18.0-1717818597-organization-mfa-requirement.js +14 -0
- package/alterations-js/1.18.0-1718340884-rename-org-email-domains-and-add-jit-roles-table.d.ts +3 -0
- package/alterations-js/1.18.0-1718340884-rename-org-email-domains-and-add-jit-roles-table.js +51 -0
- package/alterations-js/1.18.0-1718594164-add-agree-to-terms-policy.d.ts +3 -0
- package/alterations-js/1.18.0-1718594164-add-agree-to-terms-policy.js +34 -0
- package/alterations-js/1.18.0-1718785576-organization-application-relations.d.ts +3 -0
- package/alterations-js/1.18.0-1718785576-organization-application-relations.js +32 -0
- package/alterations-js/1.18.0-1718786576-organization-jit-sso-connectors.d.ts +3 -0
- package/alterations-js/1.18.0-1718786576-organization-jit-sso-connectors.js +26 -0
- package/alterations-js/1.18.0-1718807616-organization-role-application-relations.d.ts +3 -0
- package/alterations-js/1.18.0-1718807616-organization-role-application-relations.js +29 -0
- package/alterations-js/1.18.0-1718865814-add-subject-tokens.d.ts +3 -0
- package/alterations-js/1.18.0-1718865814-add-subject-tokens.js +31 -0
- package/alterations-js/1.18.0-1719014832-organization-role-types.d.ts +3 -0
- package/alterations-js/1.18.0-1719014832-organization-role-types.js +31 -0
- package/alterations-js/1.18.0-1719221205-fix-functions.d.ts +7 -0
- package/alterations-js/1.18.0-1719221205-fix-functions.js +20 -0
- package/alterations-js/1.18.0-1719312694-custom-ui-assets.d.ts +3 -0
- package/alterations-js/1.18.0-1719312694-custom-ui-assets.js +14 -0
- package/alterations-js/utils/1716643968-id-generation.d.ts +19 -0
- package/alterations-js/utils/1716643968-id-generation.js +26 -0
- package/lib/consts/subscriptions.d.ts +9 -6
- package/lib/consts/subscriptions.js +8 -5
- package/lib/db-entries/custom-types.d.ts +5 -0
- package/lib/db-entries/custom-types.js +6 -0
- package/lib/db-entries/index.d.ts +6 -0
- package/lib/db-entries/index.js +6 -0
- package/lib/db-entries/organization-application-relation.d.ts +20 -0
- package/lib/db-entries/organization-application-relation.js +29 -0
- package/lib/db-entries/organization-jit-email-domain.d.ts +24 -0
- package/lib/db-entries/organization-jit-email-domain.js +29 -0
- package/lib/db-entries/organization-jit-role.d.ts +24 -0
- package/lib/db-entries/organization-jit-role.js +29 -0
- package/lib/db-entries/organization-jit-sso-connector.d.ts +22 -0
- package/lib/db-entries/organization-jit-sso-connector.js +29 -0
- package/lib/db-entries/organization-role-application-relation.d.ts +22 -0
- package/lib/db-entries/organization-role-application-relation.js +33 -0
- package/lib/db-entries/organization-role.d.ts +6 -1
- package/lib/db-entries/organization-role.js +5 -0
- package/lib/db-entries/organization.d.ts +5 -1
- package/lib/db-entries/organization.js +4 -0
- package/lib/db-entries/role.d.ts +5 -1
- package/lib/db-entries/role.js +4 -0
- package/lib/db-entries/sign-in-experience.d.ts +11 -3
- package/lib/db-entries/sign-in-experience.js +14 -2
- package/lib/db-entries/subject-token.d.ts +28 -0
- package/lib/db-entries/subject-token.js +50 -0
- package/lib/foundations/jsonb-types/hooks.d.ts +18 -20
- package/lib/foundations/jsonb-types/hooks.js +21 -21
- package/lib/foundations/jsonb-types/oidc-module.d.ts +33 -1
- package/lib/foundations/jsonb-types/oidc-module.js +2 -0
- package/lib/foundations/jsonb-types/sign-in-experience.d.ts +14 -0
- package/lib/foundations/jsonb-types/sign-in-experience.js +3 -0
- package/lib/models/tenants.d.ts +0 -21
- package/lib/models/tenants.js +0 -3
- package/lib/seeds/cloud-api.js +1 -0
- package/lib/seeds/management-api.d.ts +4 -0
- package/lib/seeds/management-api.js +10 -0
- package/lib/seeds/sign-in-experience.js +1 -0
- package/lib/types/application.d.ts +7 -47
- package/lib/types/connector.d.ts +724 -190
- package/lib/types/consent.d.ts +1 -9
- package/lib/types/hook.d.ts +67 -6
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -0
- package/lib/types/interactions.d.ts +141 -6
- package/lib/types/interactions.js +62 -8
- package/lib/types/log/token.d.ts +2 -1
- package/lib/types/log/token.js +1 -0
- package/lib/types/logto-config/index.d.ts +10 -0
- package/lib/types/logto-config/jwt-customizer.d.ts +174 -137
- package/lib/types/logto-config/jwt-customizer.js +2 -1
- package/lib/types/mapi-proxy.js +1 -0
- package/lib/types/oidc-config.d.ts +2 -1
- package/lib/types/oidc-config.js +1 -0
- package/lib/types/organization.d.ts +12 -3
- package/lib/types/organization.js +4 -1
- package/lib/types/role.d.ts +6 -1
- package/lib/types/role.js +6 -1
- package/lib/types/sign-in-experience.d.ts +1064 -0
- package/lib/types/sign-in-experience.js +21 -0
- package/lib/types/subject-token.d.ts +12 -0
- package/lib/types/subject-token.js +5 -0
- package/lib/types/system.d.ts +4 -4
- package/lib/types/tenant-organization.d.ts +1 -0
- package/lib/types/tenant-organization.js +3 -0
- package/lib/types/user.d.ts +5 -1
- package/lib/types/user.js +5 -1
- package/lib/utils/role.d.ts +2 -0
- package/lib/utils/role.js +2 -0
- package/lib/utils/zod.d.ts +1 -1
- package/package.json +8 -7
- package/tables/_after_all.sql +0 -27
- package/tables/applications.sql +5 -0
- package/tables/organization_application_relations.sql +14 -0
- package/tables/organization_jit_email_domains.sql +13 -0
- package/tables/organization_jit_roles.sql +14 -0
- package/tables/organization_jit_sso_connectors.sql +13 -0
- package/tables/organization_role_application_relations.sql +18 -0
- package/tables/organization_role_user_relations.sql +3 -1
- package/tables/organization_roles.sql +8 -1
- package/tables/organizations.sql +2 -0
- package/tables/roles.sql +2 -0
- package/tables/service_logs.sql +1 -2
- package/tables/sign_in_experiences.sql +5 -0
- package/tables/subject_tokens.sql +16 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { connectorMetadataGuard, googleOneTapConfigGuard, } from '@logto/connector-kit';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { SignInExperiences } from '../db-entries/index.js';
|
|
4
|
+
import { ssoConnectorMetadataGuard } from './sso-connector.js';
|
|
5
|
+
export const guardFullSignInExperience = SignInExperiences.guard.extend({
|
|
6
|
+
socialConnectors: connectorMetadataGuard
|
|
7
|
+
.omit({
|
|
8
|
+
description: true,
|
|
9
|
+
configTemplate: true,
|
|
10
|
+
formItems: true,
|
|
11
|
+
readme: true,
|
|
12
|
+
customData: true,
|
|
13
|
+
})
|
|
14
|
+
.array(),
|
|
15
|
+
ssoConnectors: ssoConnectorMetadataGuard.array(),
|
|
16
|
+
forgotPassword: z.object({ phone: z.boolean(), email: z.boolean() }),
|
|
17
|
+
isDevelopmentTenant: z.boolean(),
|
|
18
|
+
googleOneTap: googleOneTapConfigGuard
|
|
19
|
+
.extend({ clientId: z.string(), connectorId: z.string() })
|
|
20
|
+
.optional(),
|
|
21
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type z } from 'zod';
|
|
2
|
+
export declare const subjectTokenResponseGuard: z.ZodObject<{
|
|
3
|
+
subjectToken: z.ZodString;
|
|
4
|
+
expiresIn: z.ZodNumber;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
subjectToken: string;
|
|
7
|
+
expiresIn: number;
|
|
8
|
+
}, {
|
|
9
|
+
subjectToken: string;
|
|
10
|
+
expiresIn: number;
|
|
11
|
+
}>;
|
|
12
|
+
export type SubjectTokenResponse = z.infer<typeof subjectTokenResponseGuard>;
|
package/lib/types/system.d.ts
CHANGED
|
@@ -96,17 +96,17 @@ export declare const sendgridEmailServiceConfigGuard: z.ZodObject<{
|
|
|
96
96
|
fromName: z.ZodString;
|
|
97
97
|
fromEmail: z.ZodString;
|
|
98
98
|
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
fromEmail: string;
|
|
99
100
|
provider: EmailServiceProvider;
|
|
100
101
|
apiKey: string;
|
|
101
102
|
templateId: string;
|
|
102
103
|
fromName: string;
|
|
103
|
-
fromEmail: string;
|
|
104
104
|
}, {
|
|
105
|
+
fromEmail: string;
|
|
105
106
|
provider: EmailServiceProvider;
|
|
106
107
|
apiKey: string;
|
|
107
108
|
templateId: string;
|
|
108
109
|
fromName: string;
|
|
109
|
-
fromEmail: string;
|
|
110
110
|
}>;
|
|
111
111
|
export type SendgridEmailServiceConfig = z.infer<typeof sendgridEmailServiceConfigGuard>;
|
|
112
112
|
export declare const emailServiceConfigGuard: z.ZodDiscriminatedUnion<"provider", [z.ZodObject<{
|
|
@@ -116,17 +116,17 @@ export declare const emailServiceConfigGuard: z.ZodDiscriminatedUnion<"provider"
|
|
|
116
116
|
fromName: z.ZodString;
|
|
117
117
|
fromEmail: z.ZodString;
|
|
118
118
|
}, "strip", z.ZodTypeAny, {
|
|
119
|
+
fromEmail: string;
|
|
119
120
|
provider: EmailServiceProvider;
|
|
120
121
|
apiKey: string;
|
|
121
122
|
templateId: string;
|
|
122
123
|
fromName: string;
|
|
123
|
-
fromEmail: string;
|
|
124
124
|
}, {
|
|
125
|
+
fromEmail: string;
|
|
125
126
|
provider: EmailServiceProvider;
|
|
126
127
|
apiKey: string;
|
|
127
128
|
templateId: string;
|
|
128
129
|
fromName: string;
|
|
129
|
-
fromEmail: string;
|
|
130
130
|
}>]>;
|
|
131
131
|
export type EmailServiceConfig = z.infer<typeof emailServiceConfigGuard>;
|
|
132
132
|
export declare enum EmailServiceProviderKey {
|
|
@@ -98,6 +98,7 @@ export declare enum TenantRole {
|
|
|
98
98
|
* id: 'collaborator',
|
|
99
99
|
* name: 'collaborator',
|
|
100
100
|
* description: 'Collaborator of the tenant, who has permissions to operate the tenant data, but not the tenant settings.',
|
|
101
|
+
* type: RoleType.User,
|
|
101
102
|
* });
|
|
102
103
|
* ```
|
|
103
104
|
*
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This module provides utilities to manage tenant organizations.
|
|
8
8
|
*/
|
|
9
|
+
import { RoleType, } from '../db-entries/index.js';
|
|
9
10
|
import { adminTenantId } from '../seeds/tenant.js';
|
|
10
11
|
/** Given a tenant ID, return the corresponding organization ID in the admin tenant. */
|
|
11
12
|
export const getTenantOrganizationId = (tenantId) => `t-${tenantId}`;
|
|
@@ -129,6 +130,7 @@ const tenantRoleDescriptions = Object.freeze({
|
|
|
129
130
|
* id: 'collaborator',
|
|
130
131
|
* name: 'collaborator',
|
|
131
132
|
* description: 'Collaborator of the tenant, who has permissions to operate the tenant data, but not the tenant settings.',
|
|
133
|
+
* type: RoleType.User,
|
|
132
134
|
* });
|
|
133
135
|
* ```
|
|
134
136
|
*
|
|
@@ -139,6 +141,7 @@ export const getTenantRole = (role) => Object.freeze({
|
|
|
139
141
|
id: role,
|
|
140
142
|
name: role,
|
|
141
143
|
description: tenantRoleDescriptions[role],
|
|
144
|
+
type: RoleType.User,
|
|
142
145
|
});
|
|
143
146
|
/**
|
|
144
147
|
* The dictionary of tenant roles and their corresponding scopes.
|
package/lib/types/user.d.ts
CHANGED
|
@@ -361,7 +361,11 @@ export declare const userMfaVerificationResponseGuard: z.ZodArray<z.ZodObject<{
|
|
|
361
361
|
remainCodes?: number | undefined;
|
|
362
362
|
}>, "many">;
|
|
363
363
|
export type UserMfaVerificationResponse = z.infer<typeof userMfaVerificationResponseGuard>;
|
|
364
|
-
/**
|
|
364
|
+
/**
|
|
365
|
+
* Internal read-only roles for user tenants.
|
|
366
|
+
*
|
|
367
|
+
* @deprecated We don't use internal roles anymore.
|
|
368
|
+
*/
|
|
365
369
|
export declare enum InternalRole {
|
|
366
370
|
/**
|
|
367
371
|
* Internal admin role for Machine-to-Machine apps in Logto user tenants.
|
package/lib/types/user.js
CHANGED
|
@@ -33,7 +33,11 @@ export const userMfaVerificationResponseGuard = z
|
|
|
33
33
|
remainCodes: z.number().optional(),
|
|
34
34
|
})
|
|
35
35
|
.array();
|
|
36
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Internal read-only roles for user tenants.
|
|
38
|
+
*
|
|
39
|
+
* @deprecated We don't use internal roles anymore.
|
|
40
|
+
*/
|
|
37
41
|
export var InternalRole;
|
|
38
42
|
(function (InternalRole) {
|
|
39
43
|
/**
|
package/lib/utils/role.d.ts
CHANGED
package/lib/utils/role.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
/** @deprecated We don't restrict roles in the database anymore. */
|
|
1
2
|
export const internalRolePrefix = '#internal:';
|
|
3
|
+
/** @deprecated We don't restrict roles in the database anymore. */
|
|
2
4
|
export const isInternalRole = (roleName) => roleName.startsWith(internalRolePrefix);
|
package/lib/utils/zod.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/schemas",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@silverhand/eslint-config": "6.0.1",
|
|
28
|
-
"@silverhand/essentials": "^2.9.
|
|
28
|
+
"@silverhand/essentials": "^2.9.1",
|
|
29
29
|
"@silverhand/slonik": "31.0.0-beta.2",
|
|
30
30
|
"@silverhand/ts-config": "6.0.0",
|
|
31
31
|
"@types/inquirer": "^9.0.0",
|
|
@@ -63,13 +63,14 @@
|
|
|
63
63
|
},
|
|
64
64
|
"prettier": "@silverhand/eslint-config/.prettierrc",
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@logto/connector-kit": "^
|
|
67
|
-
"@logto/core-kit": "^2.
|
|
66
|
+
"@logto/connector-kit": "^4.0.0",
|
|
67
|
+
"@logto/core-kit": "^2.5.0",
|
|
68
68
|
"@logto/language-kit": "^1.1.0",
|
|
69
|
-
"@logto/phrases": "^1.
|
|
70
|
-
"@logto/phrases-experience": "^1.
|
|
69
|
+
"@logto/phrases": "^1.12.0",
|
|
70
|
+
"@logto/phrases-experience": "^1.7.0",
|
|
71
71
|
"@logto/shared": "^3.1.1",
|
|
72
|
-
"@withtyped/server": "^0.13.6"
|
|
72
|
+
"@withtyped/server": "^0.13.6",
|
|
73
|
+
"nanoid": "^5.0.1"
|
|
73
74
|
},
|
|
74
75
|
"peerDependencies": {
|
|
75
76
|
"zod": "^3.22.4"
|
package/tables/_after_all.sql
CHANGED
|
@@ -32,30 +32,3 @@ revoke all privileges
|
|
|
32
32
|
revoke all privileges
|
|
33
33
|
on table service_logs
|
|
34
34
|
from logto_tenant_${database};
|
|
35
|
-
|
|
36
|
-
---- Create policies to make internal roles read-only ----
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Note:
|
|
40
|
-
*
|
|
41
|
-
* Internal roles have scope preset and they are read-only, but we do not
|
|
42
|
-
* limit user or application assignment since it's business logic.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
-- Restrict direct role modification
|
|
46
|
-
create policy roles_select on roles
|
|
47
|
-
for select using (true);
|
|
48
|
-
|
|
49
|
-
drop policy roles_modification on roles;
|
|
50
|
-
create policy roles_modification on roles
|
|
51
|
-
using (not starts_with(name, '#internal:'));
|
|
52
|
-
|
|
53
|
-
-- Restrict role - scope modification
|
|
54
|
-
create policy roles_scopes_select on roles_scopes
|
|
55
|
-
for select using (true);
|
|
56
|
-
|
|
57
|
-
drop policy roles_scopes_modification on roles_scopes;
|
|
58
|
-
create policy roles_scopes_modification on roles_scopes
|
|
59
|
-
using (not starts_with((select roles.name from roles where roles.id = role_id), '#internal:'));
|
|
60
|
-
|
|
61
|
-
---- TODO: Make internal API Resources read-only ----
|
package/tables/applications.sql
CHANGED
|
@@ -33,3 +33,8 @@ create unique index applications__protected_app_metadata_custom_domain
|
|
|
33
33
|
on applications (
|
|
34
34
|
(protected_app_metadata->'customDomains'->0->>'domain')
|
|
35
35
|
);
|
|
36
|
+
|
|
37
|
+
create function check_application_type(application_id varchar(21), target_type application_type) returns boolean as
|
|
38
|
+
$$ begin
|
|
39
|
+
return (select type from applications where id = application_id) = target_type;
|
|
40
|
+
end; $$ language plpgsql set search_path = public;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/** The relations between organizations and applications. It indicates membership of applications in organizations. For now only machine-to-machine applications are supported. */
|
|
4
|
+
create table organization_application_relations (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
organization_id varchar(21) not null
|
|
8
|
+
references organizations (id) on update cascade on delete cascade,
|
|
9
|
+
application_id varchar(21) not null
|
|
10
|
+
references applications (id) on update cascade on delete cascade,
|
|
11
|
+
primary key (tenant_id, organization_id, application_id),
|
|
12
|
+
constraint application_type
|
|
13
|
+
check (check_application_type(application_id, 'MachineToMachine'))
|
|
14
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/** The email domains that will automatically assign users into an organization when they sign up or are added through the Management API. */
|
|
4
|
+
create table organization_jit_email_domains (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
/** The ID of the organization. */
|
|
8
|
+
organization_id varchar(21) not null
|
|
9
|
+
references organizations (id) on update cascade on delete cascade,
|
|
10
|
+
/** The email domain that will be automatically provisioned. */
|
|
11
|
+
email_domain varchar(128) not null,
|
|
12
|
+
primary key (tenant_id, organization_id, email_domain)
|
|
13
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/** The organization roles that will be automatically provisioned to users when they join an organization through JIT. */
|
|
4
|
+
create table organization_jit_roles (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
/** The ID of the organization. */
|
|
8
|
+
organization_id varchar(21) not null
|
|
9
|
+
references organizations (id) on update cascade on delete cascade,
|
|
10
|
+
/** The organization role ID that will be automatically provisioned. */
|
|
11
|
+
organization_role_id varchar(21) not null
|
|
12
|
+
references organization_roles (id) on update cascade on delete cascade,
|
|
13
|
+
primary key (tenant_id, organization_id, organization_role_id)
|
|
14
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/** The enterprise SSO connectors that will automatically assign users into an organization when they are authenticated via the SSO connector for the first time. */
|
|
4
|
+
create table organization_jit_sso_connectors (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
/** The ID of the organization. */
|
|
8
|
+
organization_id varchar(21) not null
|
|
9
|
+
references organizations (id) on update cascade on delete cascade,
|
|
10
|
+
sso_connector_id varchar(128) not null
|
|
11
|
+
references sso_connectors (id) on update cascade on delete cascade,
|
|
12
|
+
primary key (tenant_id, organization_id, sso_connector_id)
|
|
13
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* init_order = 3 */
|
|
2
|
+
|
|
3
|
+
/** The relations between organizations, organization roles, and applications. A relation means that an application has a role in an organization. */
|
|
4
|
+
create table organization_role_application_relations (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
organization_id varchar(21) not null,
|
|
8
|
+
organization_role_id varchar(21) not null
|
|
9
|
+
references organization_roles (id) on update cascade on delete cascade,
|
|
10
|
+
application_id varchar(21) not null,
|
|
11
|
+
primary key (tenant_id, organization_id, organization_role_id, application_id),
|
|
12
|
+
/** Application's roles in an organization should be synchronized with the application's membership in the organization. */
|
|
13
|
+
foreign key (tenant_id, organization_id, application_id)
|
|
14
|
+
references organization_application_relations (tenant_id, organization_id, application_id)
|
|
15
|
+
on update cascade on delete cascade,
|
|
16
|
+
constraint organization_role_application_relations__role_type
|
|
17
|
+
check (check_organization_role_type(organization_role_id, 'MachineToMachine'))
|
|
18
|
+
);
|
|
@@ -12,5 +12,7 @@ create table organization_role_user_relations (
|
|
|
12
12
|
/** User's roles in an organization should be synchronized with the user's membership in the organization. */
|
|
13
13
|
foreign key (tenant_id, organization_id, user_id)
|
|
14
14
|
references organization_user_relations (tenant_id, organization_id, user_id)
|
|
15
|
-
on update cascade on delete cascade
|
|
15
|
+
on update cascade on delete cascade,
|
|
16
|
+
constraint organization_role_user_relations__role_type
|
|
17
|
+
check (check_organization_role_type(organization_role_id, 'User'))
|
|
16
18
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* init_order = 1 */
|
|
1
|
+
/* init_order = 1.1 */
|
|
2
2
|
|
|
3
3
|
/** The roles defined by the organization template. */
|
|
4
4
|
create table organization_roles (
|
|
@@ -10,6 +10,8 @@ create table organization_roles (
|
|
|
10
10
|
name varchar(128) not null,
|
|
11
11
|
/** A brief description of the organization role. */
|
|
12
12
|
description varchar(256),
|
|
13
|
+
/** The type of the organization role. Same as the `type` field in the `roles` table. */
|
|
14
|
+
type role_type not null default 'User',
|
|
13
15
|
primary key (id),
|
|
14
16
|
constraint organization_roles__name
|
|
15
17
|
unique (tenant_id, name)
|
|
@@ -17,3 +19,8 @@ create table organization_roles (
|
|
|
17
19
|
|
|
18
20
|
create index organization_roles__id
|
|
19
21
|
on organization_roles (tenant_id, id);
|
|
22
|
+
|
|
23
|
+
create function check_organization_role_type(role_id varchar(21), target_type role_type) returns boolean as
|
|
24
|
+
$$ begin
|
|
25
|
+
return (select type from organization_roles where id = role_id) = target_type;
|
|
26
|
+
end; $$ language plpgsql set search_path = public;
|
package/tables/organizations.sql
CHANGED
|
@@ -12,6 +12,8 @@ create table organizations (
|
|
|
12
12
|
description varchar(256),
|
|
13
13
|
/** Additional data associated with the organization. */
|
|
14
14
|
custom_data jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
15
|
+
/** Whether multi-factor authentication configuration is required for the members of the organization. */
|
|
16
|
+
is_mfa_required boolean not null default false,
|
|
15
17
|
/** When the organization was created. */
|
|
16
18
|
created_at timestamptz not null default(now()),
|
|
17
19
|
primary key (id)
|
package/tables/roles.sql
CHANGED
|
@@ -9,6 +9,8 @@ create table roles (
|
|
|
9
9
|
name varchar(128) not null,
|
|
10
10
|
description varchar(128) not null,
|
|
11
11
|
type role_type not null default 'User',
|
|
12
|
+
/** If the role is the default role for a new user. Should be ignored for `MachineToMachine` roles. */
|
|
13
|
+
is_default boolean not null default false,
|
|
12
14
|
primary key (id),
|
|
13
15
|
constraint roles__name
|
|
14
16
|
unique (tenant_id, name)
|
package/tables/service_logs.sql
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
create table service_logs (
|
|
2
2
|
id varchar(21) not null,
|
|
3
|
-
tenant_id varchar(21) not null
|
|
4
|
-
references tenants (id) on update cascade on delete cascade,
|
|
3
|
+
tenant_id varchar(21) not null,
|
|
5
4
|
type varchar(64) not null,
|
|
6
5
|
payload jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
7
6
|
created_at timestamptz not null default(now()),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
create type sign_in_mode as enum ('SignIn', 'Register', 'SignInAndRegister');
|
|
2
|
+
create type agree_to_terms_policy as enum ('Automatic', 'ManualRegistrationOnly', 'Manual');
|
|
2
3
|
|
|
3
4
|
create table sign_in_experiences (
|
|
4
5
|
tenant_id varchar(21) not null
|
|
@@ -9,12 +10,16 @@ create table sign_in_experiences (
|
|
|
9
10
|
language_info jsonb /* @use LanguageInfo */ not null,
|
|
10
11
|
terms_of_use_url varchar(2048),
|
|
11
12
|
privacy_policy_url varchar(2048),
|
|
13
|
+
/** The policy that determines how users agree to the terms of use and privacy policy. */
|
|
14
|
+
agree_to_terms_policy agree_to_terms_policy not null default 'Automatic',
|
|
12
15
|
sign_in jsonb /* @use SignIn */ not null,
|
|
13
16
|
sign_up jsonb /* @use SignUp */ not null,
|
|
17
|
+
social_sign_in jsonb /* @use SocialSignIn */ not null default '{}'::jsonb,
|
|
14
18
|
social_sign_in_connector_targets jsonb /* @use ConnectorTargets */ not null default '[]'::jsonb,
|
|
15
19
|
sign_in_mode sign_in_mode not null default 'SignInAndRegister',
|
|
16
20
|
custom_css text,
|
|
17
21
|
custom_content jsonb /* @use CustomContent */ not null default '{}'::jsonb,
|
|
22
|
+
custom_ui_asset_id varchar(21),
|
|
18
23
|
password_policy jsonb /* @use PartialPasswordPolicy */ not null default '{}'::jsonb,
|
|
19
24
|
mfa jsonb /* @use Mfa */ not null default '{}'::jsonb,
|
|
20
25
|
single_sign_on_enabled boolean not null default false,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
create table subject_tokens (
|
|
2
|
+
tenant_id varchar(21) not null
|
|
3
|
+
references tenants (id) on update cascade on delete cascade,
|
|
4
|
+
id varchar(25) not null,
|
|
5
|
+
context jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
6
|
+
expires_at timestamptz not null,
|
|
7
|
+
consumed_at timestamptz,
|
|
8
|
+
user_id varchar(21) not null
|
|
9
|
+
references users (id) on update cascade on delete cascade,
|
|
10
|
+
created_at timestamptz not null default(now()),
|
|
11
|
+
/* It is intented to not reference to user or application table, it can be userId or applicationId, for audit only */
|
|
12
|
+
creator_id varchar(32) not null,
|
|
13
|
+
primary key (id)
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
create index subject_token__id on subject_tokens (tenant_id, id);
|