@logto/schemas 1.13.0 → 1.13.1
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.13.1-1707360939-grant-is-suspended-read-permission.ts +39 -0
- package/alterations-js/1.13.1-1707360939-grant-is-suspended-read-permission.d.ts +6 -0
- package/alterations-js/1.13.1-1707360939-grant-is-suspended-read-permission.js +31 -0
- package/lib/foundations/jsonb-types/users.d.ts +1 -2
- package/lib/foundations/jsonb-types/users.js +1 -1
- package/lib/seeds/cloud-api.d.ts +3 -1
- package/lib/seeds/cloud-api.js +2 -0
- package/package.json +1 -1
- package/tables/_after_all.sql +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type CommonQueryMethods, sql } from 'slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
const getDatabaseName = async (pool: CommonQueryMethods) => {
|
|
6
|
+
const { currentDatabase } = await pool.one<{ currentDatabase: string }>(sql`
|
|
7
|
+
select current_database();
|
|
8
|
+
`);
|
|
9
|
+
|
|
10
|
+
return currentDatabase.replaceAll('-', '_');
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Grant read permission to the is_suspended column in the tenants table to the logto_tenant_<databaseName> role.
|
|
15
|
+
*/
|
|
16
|
+
const alteration: AlterationScript = {
|
|
17
|
+
up: async (pool) => {
|
|
18
|
+
const databaseName = await getDatabaseName(pool);
|
|
19
|
+
const baseRoleId = sql.identifier([`logto_tenant_${databaseName}`]);
|
|
20
|
+
|
|
21
|
+
await pool.query(sql`
|
|
22
|
+
grant select (is_suspended)
|
|
23
|
+
on table tenants
|
|
24
|
+
to ${baseRoleId}
|
|
25
|
+
`);
|
|
26
|
+
},
|
|
27
|
+
down: async (pool) => {
|
|
28
|
+
const databaseName = await getDatabaseName(pool);
|
|
29
|
+
const baseRoleId = sql.identifier([`logto_tenant_${databaseName}`]);
|
|
30
|
+
|
|
31
|
+
await pool.query(sql`
|
|
32
|
+
revoke select(is_suspended)
|
|
33
|
+
on table tenants
|
|
34
|
+
from ${baseRoleId}
|
|
35
|
+
`);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default alteration;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { sql } from 'slonik';
|
|
2
|
+
const getDatabaseName = async (pool) => {
|
|
3
|
+
const { currentDatabase } = await pool.one(sql `
|
|
4
|
+
select current_database();
|
|
5
|
+
`);
|
|
6
|
+
return currentDatabase.replaceAll('-', '_');
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Grant read permission to the is_suspended column in the tenants table to the logto_tenant_<databaseName> role.
|
|
10
|
+
*/
|
|
11
|
+
const alteration = {
|
|
12
|
+
up: async (pool) => {
|
|
13
|
+
const databaseName = await getDatabaseName(pool);
|
|
14
|
+
const baseRoleId = sql.identifier([`logto_tenant_${databaseName}`]);
|
|
15
|
+
await pool.query(sql `
|
|
16
|
+
grant select (is_suspended)
|
|
17
|
+
on table tenants
|
|
18
|
+
to ${baseRoleId}
|
|
19
|
+
`);
|
|
20
|
+
},
|
|
21
|
+
down: async (pool) => {
|
|
22
|
+
const databaseName = await getDatabaseName(pool);
|
|
23
|
+
const baseRoleId = sql.identifier([`logto_tenant_${databaseName}`]);
|
|
24
|
+
await pool.query(sql `
|
|
25
|
+
revoke select(is_suspended)
|
|
26
|
+
on table tenants
|
|
27
|
+
from ${baseRoleId}
|
|
28
|
+
`);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export default alteration;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { MfaFactor } from './sign-in-experience.js';
|
|
3
3
|
export declare const roleNamesGuard: z.ZodArray<z.ZodString, "many">;
|
|
4
|
-
declare const identityGuard: z.ZodObject<{
|
|
4
|
+
export declare const identityGuard: z.ZodObject<{
|
|
5
5
|
userId: z.ZodString;
|
|
6
6
|
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -282,4 +282,3 @@ export declare const mfaVerificationsGuard: z.ZodArray<z.ZodDiscriminatedUnion<"
|
|
|
282
282
|
lastUsedAt?: string | undefined;
|
|
283
283
|
}>]>, "many">;
|
|
284
284
|
export type MfaVerifications = z.infer<typeof mfaVerificationsGuard>;
|
|
285
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { MfaFactor } from './sign-in-experience.js';
|
|
3
3
|
export const roleNamesGuard = z.string().array();
|
|
4
|
-
const identityGuard = z.object({
|
|
4
|
+
export const identityGuard = z.object({
|
|
5
5
|
userId: z.string(),
|
|
6
6
|
details: z.record(z.unknown()).optional(), // Connector's userinfo details, schemaless
|
|
7
7
|
});
|
package/lib/seeds/cloud-api.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ export declare enum CloudScope {
|
|
|
12
12
|
/** The user can see and manage affiliates, including create, update, and delete. */
|
|
13
13
|
ManageAffiliate = "manage:affiliate",
|
|
14
14
|
/** The user can create new affiliates and logs. */
|
|
15
|
-
CreateAffiliate = "create:affiliate"
|
|
15
|
+
CreateAffiliate = "create:affiliate",
|
|
16
|
+
/** The user can cleanup outdated logs. */
|
|
17
|
+
CleanupOutdatedLogs = "cleanup:outdated-logs"
|
|
16
18
|
}
|
|
17
19
|
export declare const createCloudApi: () => readonly [UpdateAdminData, ...CreateScope[]];
|
|
18
20
|
export declare const createTenantApplicationRole: () => Readonly<Role>;
|
package/lib/seeds/cloud-api.js
CHANGED
|
@@ -16,6 +16,8 @@ export var CloudScope;
|
|
|
16
16
|
CloudScope["ManageAffiliate"] = "manage:affiliate";
|
|
17
17
|
/** The user can create new affiliates and logs. */
|
|
18
18
|
CloudScope["CreateAffiliate"] = "create:affiliate";
|
|
19
|
+
/** The user can cleanup outdated logs. */
|
|
20
|
+
CloudScope["CleanupOutdatedLogs"] = "cleanup:outdated-logs";
|
|
19
21
|
})(CloudScope || (CloudScope = {}));
|
|
20
22
|
export const createCloudApi = () => {
|
|
21
23
|
const resourceId = generateStandardId();
|
package/package.json
CHANGED
package/tables/_after_all.sql
CHANGED
|
@@ -13,7 +13,7 @@ revoke all privileges
|
|
|
13
13
|
from logto_tenant_${database};
|
|
14
14
|
|
|
15
15
|
-- Allow limited select to perform the RLS policy query in `after_each` (using select ... from tenants ...)
|
|
16
|
-
grant select (id, db_user)
|
|
16
|
+
grant select (id, db_user, is_suspended)
|
|
17
17
|
on table tenants
|
|
18
18
|
to logto_tenant_${database};
|
|
19
19
|
|