diff --git a/src/pages/Secrets/KeyValue/KeyValueView.tsx b/src/pages/Secrets/KeyValue/KeyValueView.tsx index 59aa49e..ee29ae9 100644 --- a/src/pages/Secrets/KeyValue/KeyValueView.tsx +++ b/src/pages/Secrets/KeyValue/KeyValueView.tsx @@ -2,7 +2,7 @@ import { Component, JSX, render } from "preact"; import { DoesNotExistError } from "../../../types/internalErrors"; import { Page } from "../../../types/Page"; import { SecretTitleElement } from "../SecretTitleElement"; -import { getCapsPath } from "../../../api/sys/getCapabilities"; +import { getCapabilitiesPath, getCapsPath } from "../../../api/sys/getCapabilities"; import { getSecrets } from "../../../api/kv/getSecrets"; import { setErrorText } from "../../../pageUtils"; import i18next from "i18next"; @@ -124,12 +124,19 @@ export class KeyValueViewPage extends Page { } } async render(): Promise { - const caps = await getCapsPath("/sys/mounts/" + this.state.baseMount); + const mountsPath = "/sys/mounts/" + this.state.baseMount; + const currentPath = this.state.baseMount + this.state.secretPath.join("/"); + const caps = await getCapabilitiesPath([ + mountsPath, + currentPath + ]); + const mountCaps = caps[mountsPath]; + const pathCaps = caps[currentPath]; render( <>

- {caps.includes("create") && ( + {pathCaps.includes("create") && ( )} - {this.state.secretPath.length == 0 && caps.includes("delete") && ( + {this.state.secretPath.length == 0 && mountCaps.includes("delete") && ( )} - {caps.includes("delete") && ( + {mountCaps.includes("delete") && ( )}

-
-
{ await (async () => { diff --git a/src/pages/Secrets/Transit/TransitView.tsx b/src/pages/Secrets/Transit/TransitView.tsx index 3a7dc13..b453fcb 100644 --- a/src/pages/Secrets/Transit/TransitView.tsx +++ b/src/pages/Secrets/Transit/TransitView.tsx @@ -1,7 +1,7 @@ import { Component, JSX, render } from "preact"; import { Page } from "../../../types/Page"; import { SecretTitleElement } from "../SecretTitleElement"; -import { getCapsPath } from "../../../api/sys/getCapabilities"; +import { getCapabilitiesPath, getCapsPath } from "../../../api/sys/getCapabilities"; import { getTransitKeys } from "../../../api/transit/getTransitKeys"; import i18next from "i18next"; @@ -81,12 +81,18 @@ export class TransitViewPage extends Page { async render(): Promise { this.state.secretItem = ""; - const caps = await getCapsPath("/sys/mounts/" + this.state.baseMount); + const mountsPath = "/sys/mounts/" + this.state.baseMount; + const caps = await getCapabilitiesPath([ + mountsPath, + this.state.baseMount, + ]); + const mountCaps = caps[mountsPath]; + const transitCaps = caps[this.state.baseMount]; render( <>

- {caps.includes("create") && ( + {transitCaps.includes("create") && ( )} - {caps.includes("delete") && ( + {mountCaps.includes("delete") && (