@stoker-platform/cli 0.5.144 → 0.5.145

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.
@@ -10,7 +10,7 @@ const Users: GenerateSchema = (): CollectionSchema => {
10
10
  },
11
11
  auth: true,
12
12
  access: {
13
- auth: ["Admin"],
13
+ auth: { roles: ["Admin"] },
14
14
  operations: {
15
15
  assignable: ["Admin"],
16
16
  read: ["Admin"],
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/cli",
3
- "version": "0.5.143",
3
+ "version": "0.5.144",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "./lib/src/main.js",
@@ -24,7 +24,7 @@
24
24
  "@google-cloud/secret-manager": "^6.1.2",
25
25
  "@google-cloud/storage": "^7.19.0",
26
26
  "@inquirer/prompts": "^8.5.2",
27
- "@stoker-platform/node-client": "0.5.89",
27
+ "@stoker-platform/node-client": "0.5.90",
28
28
  "@stoker-platform/types": "0.5.65",
29
29
  "@stoker-platform/utils": "0.5.79",
30
30
  "algoliasearch": "^5.53.0",
@@ -817,11 +817,21 @@ export const lintSchema = async (noLog = false) => {
817
817
  }
818
818
  }
819
819
  if (authAccess) {
820
- for (const role of authAccess) {
820
+ for (const role of authAccess.roles) {
821
821
  if (!roles.includes(role)) {
822
822
  errors.push(`Collection ${collectionName} has an auth role ${role} that does not exist`);
823
823
  }
824
824
  }
825
+ if (authAccess.assignable) {
826
+ for (const role of authAccess.assignable) {
827
+ if (!roles.includes(role)) {
828
+ errors.push(`Collection ${collectionName} has an auth assignable role ${role} that does not exist`);
829
+ }
830
+ else if (!authAccess.roles.includes(role)) {
831
+ errors.push(`Collection ${collectionName} has an auth assignable role ${role} that is not included in auth roles`);
832
+ }
833
+ }
834
+ }
825
835
  }
826
836
  if (serverReadOnly) {
827
837
  for (const role of serverReadOnly) {
@@ -16,10 +16,13 @@ export const auditPermissions = async (options) => {
16
16
  for (const collection of Object.values(schema.collections)) {
17
17
  const { labels, access } = collection;
18
18
  if (access.auth) {
19
- if (!access.auth.includes(permission.Role) && permission.collections[labels.collection]?.auth) {
19
+ if (!access.auth.roles.includes(permission.Role) &&
20
+ permission.collections[labels.collection]?.auth) {
20
21
  mismatches.push(`*** User ${doc.id} has excess auth permission for ${labels.collection} collection ***`);
21
22
  }
22
- if (access.auth.includes(permission.Role) && !permission.collections[labels.collection]?.auth) {
23
+ if (access.auth.roles.includes(permission.Role) &&
24
+ !access.auth.assignable?.includes(permission.Role) &&
25
+ !permission.collections[labels.collection]?.auth) {
23
26
  mismatches.push(`User ${doc.id} is missing auth permission for ${labels.collection} collection`);
24
27
  }
25
28
  }
@@ -121,7 +121,9 @@ export const addRecordPrompt = async (tenantId, collectionName, fullAccess, mode
121
121
  }
122
122
  }
123
123
  }
124
- if (collection.auth && collection.access.auth?.includes(record.Role)) {
124
+ if (collection.auth &&
125
+ collection.access.auth?.roles?.includes(record.Role) &&
126
+ !collection.access.auth?.assignable?.includes(record.Role)) {
125
127
  // eslint-disable-next-line security/detect-object-injection
126
128
  user.permissions.collections[collectionName].auth = true;
127
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/cli",
3
- "version": "0.5.144",
3
+ "version": "0.5.145",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "./lib/src/main.js",
@@ -24,9 +24,9 @@
24
24
  "@google-cloud/secret-manager": "^6.1.2",
25
25
  "@google-cloud/storage": "^7.19.0",
26
26
  "@inquirer/prompts": "^8.5.2",
27
- "@stoker-platform/node-client": "0.5.90",
28
- "@stoker-platform/types": "0.5.65",
29
- "@stoker-platform/utils": "0.5.79",
27
+ "@stoker-platform/node-client": "0.5.91",
28
+ "@stoker-platform/types": "0.5.66",
29
+ "@stoker-platform/utils": "0.5.80",
30
30
  "algoliasearch": "^5.53.0",
31
31
  "commander": "^15.0.0",
32
32
  "cross-spawn": "^7.0.6",