Skip to content

Commit 327c6e4

Browse files
committed
add extension api groups to account owner perms
1 parent ea47438 commit 327c6e4

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inspatial/cloud",
3-
"version": "0.7.20",
3+
"version": "0.7.21",
44
"license": "Apache-2.0",
55
"exports": {
66
".": "./mod.ts",

src/api/cloud-group.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class CloudAPIGroup<
1414
description: string;
1515
label?: string;
1616
actions: Map<string, CloudAPIAction>;
17-
17+
extension: string = "";
1818
constructor(groupName: G, config: {
1919
description: string;
2020
label?: string;

src/extension/cloud-extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export class CloudExtension<
140140
this.settingsTypes = options.settingsTypes || [];
141141
this.apiGroups = [] as any;
142142
for (const actionGroup of options.apiGroups || []) {
143+
actionGroup.extension = extensionName;
143144
this.apiGroups.push(actionGroup);
144145
}
145146
this.install = options.install || (() => {});

src/in-cloud.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import type {
2828
ExtensionConfig,
2929
ExtractConfig,
3030
} from "~/cloud-config/config-types.ts";
31-
import { RoleManager } from "~/orm/roles/role.ts";
31+
import { type RoleConfig, RoleManager } from "~/orm/roles/role.ts";
3232
import { CacheTime, StaticFileHandler } from "~/static/staticFileHandler.ts";
3333
import { ExtensionManager } from "~/extension/extension-manager.ts";
3434
import type { CloudExtension } from "~/extension/cloud-extension.ts";
@@ -458,14 +458,16 @@ export class InCloud {
458458
const basicUserConfig = coreExtension?.roles.find((r) =>
459459
r.roleName === "basicUser"
460460
);
461-
if (basicUserConfig) {
462-
this.roles.addRole({
463-
...basicUserConfig,
464-
roleName: "accountAdmin",
465-
description: "Account Administrator",
466-
label: "Account Admin",
467-
});
468-
}
461+
const accountAdminConfig: RoleConfig = {
462+
...basicUserConfig,
463+
roleName: "accountAdmin",
464+
description: "Account Administrator",
465+
label: "Account Admin",
466+
apiGroups: {
467+
...basicUserConfig?.apiGroups,
468+
},
469+
};
470+
469471
for (const group of this.actionGroups.values()) {
470472
const actionsSet = new Set<string>();
471473
for (const action of group.actions.values()) {
@@ -479,7 +481,11 @@ export class InCloud {
479481
}
480482
}
481483
adminRole.apiGroups.set(group.groupName, actionsSet);
484+
if (group.extension !== "core") {
485+
accountAdminConfig.apiGroups![group.groupName] = true;
486+
}
482487
}
488+
this.roles.addRole(accountAdminConfig);
483489
}
484490
#setupOrm() {
485491
this.orm = setupOrm({

0 commit comments

Comments
 (0)