Add capability checking to secret engine buttons.
This commit is contained in:
parent
df796d3506
commit
5b0b0496be
|
@ -2,6 +2,7 @@ import { Component, JSX, render } from "preact";
|
|||
import { DoesNotExistError } from "../../../types/internalErrors";
|
||||
import { Page } from "../../../types/Page";
|
||||
import { SecretTitleElement } from "../SecretTitleElement";
|
||||
import { getCapabilitiesPath } from "../../../api/sys/getCapabilities";
|
||||
import { getSecrets } from "../../../api/kv/getSecrets";
|
||||
import { setErrorText } from "../../../pageUtils";
|
||||
import i18next from "i18next";
|
||||
|
@ -124,18 +125,22 @@ export class KeyValueViewPage extends Page {
|
|||
}
|
||||
}
|
||||
async render(): Promise<void> {
|
||||
const caps = (await getCapabilitiesPath("/sys/mounts/" + this.state.baseMount)).capabilities;
|
||||
|
||||
render(
|
||||
<>
|
||||
<p>
|
||||
<button
|
||||
class="uk-button uk-button-primary"
|
||||
onClick={async () => {
|
||||
await this.router.changePage("KEY_VALUE_NEW_SECRET");
|
||||
}}
|
||||
>
|
||||
{i18next.t("kv_view_new_btn")}
|
||||
</button>
|
||||
{this.state.secretPath.length == 0 && (
|
||||
{caps.includes("create") && (
|
||||
<button
|
||||
class="uk-button uk-button-primary"
|
||||
onClick={async () => {
|
||||
await this.router.changePage("KEY_VALUE_NEW_SECRET");
|
||||
}}
|
||||
>
|
||||
{i18next.t("kv_view_new_btn")}
|
||||
</button>
|
||||
)}
|
||||
{this.state.secretPath.length == 0 && caps.includes("delete") && (
|
||||
<button
|
||||
class="uk-button uk-button-danger"
|
||||
onClick={async () => {
|
||||
|
|
|
@ -79,25 +79,32 @@ export class TOTPViewPage extends Page {
|
|||
|
||||
async render(): Promise<void> {
|
||||
this.state.secretItem = "";
|
||||
|
||||
const caps = (await getCapabilitiesPath("/sys/mounts/" + this.state.baseMount)).capabilities;
|
||||
|
||||
render(
|
||||
<div>
|
||||
<p>
|
||||
<button
|
||||
class="uk-button uk-button-primary"
|
||||
onClick={async () => {
|
||||
await this.router.changePage("TOTP_NEW");
|
||||
}}
|
||||
>
|
||||
{i18next.t("totp_view_new_btn")}
|
||||
</button>
|
||||
<button
|
||||
class="uk-button uk-button-danger"
|
||||
onClick={async () => {
|
||||
await this.router.changePage("DELETE_SECRET_ENGINE");
|
||||
}}
|
||||
>
|
||||
{i18next.t("totp_view_delete_btn")}
|
||||
</button>
|
||||
{caps.includes("create") && (
|
||||
<button
|
||||
class="uk-button uk-button-primary"
|
||||
onClick={async () => {
|
||||
await this.router.changePage("TOTP_NEW");
|
||||
}}
|
||||
>
|
||||
{i18next.t("totp_view_new_btn")}
|
||||
</button>
|
||||
)}
|
||||
{caps.includes("delete") && (
|
||||
<button
|
||||
class="uk-button uk-button-danger"
|
||||
onClick={async () => {
|
||||
await this.router.changePage("DELETE_SECRET_ENGINE");
|
||||
}}
|
||||
>
|
||||
{i18next.t("totp_view_delete_btn")}
|
||||
</button>
|
||||
)}
|
||||
</p>
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Component, JSX, render } from "preact";
|
||||
import { Page } from "../../../types/Page";
|
||||
import { SecretTitleElement } from "../SecretTitleElement";
|
||||
import { getCapabilitiesPath } from "../../../api/sys/getCapabilities";
|
||||
import { getTransitKeys } from "../../../api/transit/getTransitKeys";
|
||||
import i18next from "i18next";
|
||||
|
||||
|
@ -79,25 +80,32 @@ export class TransitViewPage extends Page {
|
|||
|
||||
async render(): Promise<void> {
|
||||
this.state.secretItem = "";
|
||||
|
||||
const caps = (await getCapabilitiesPath("/sys/mounts/" + this.state.baseMount)).capabilities;
|
||||
|
||||
render(
|
||||
<>
|
||||
<p>
|
||||
<button
|
||||
class="uk-button uk-button-primary"
|
||||
onClick={async () => {
|
||||
await this.router.changePage("TRANSIT_NEW_KEY");
|
||||
}}
|
||||
>
|
||||
{i18next.t("transit_view_new_btn")}
|
||||
</button>
|
||||
<button
|
||||
class="uk-button uk-button-danger"
|
||||
onClick={async () => {
|
||||
await this.router.changePage("DELETE_SECRET_ENGINE");
|
||||
}}
|
||||
>
|
||||
{i18next.t("transit_view_delete_btn")}
|
||||
</button>
|
||||
{caps.includes("create") && (
|
||||
<button
|
||||
class="uk-button uk-button-primary"
|
||||
onClick={async () => {
|
||||
await this.router.changePage("TRANSIT_NEW_KEY");
|
||||
}}
|
||||
>
|
||||
{i18next.t("transit_view_new_btn")}
|
||||
</button>
|
||||
)}
|
||||
{caps.includes("delete") && (
|
||||
<button
|
||||
class="uk-button uk-button-danger"
|
||||
onClick={async () => {
|
||||
await this.router.changePage("DELETE_SECRET_ENGINE");
|
||||
}}
|
||||
>
|
||||
{i18next.t("transit_view_delete_btn")}
|
||||
</button>
|
||||
)}
|
||||
</p>
|
||||
<TransitViewListItem page={this} />
|
||||
</>,
|
||||
|
|
Loading…
Reference in a new issue