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 { DoesNotExistError } from "../../../types/internalErrors";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
|
import { getCapabilitiesPath } from "../../../api/sys/getCapabilities";
|
||||||
import { getSecrets } from "../../../api/kv/getSecrets";
|
import { getSecrets } from "../../../api/kv/getSecrets";
|
||||||
import { setErrorText } from "../../../pageUtils";
|
import { setErrorText } from "../../../pageUtils";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
@ -124,9 +125,12 @@ export class KeyValueViewPage extends Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async render(): Promise<void> {
|
async render(): Promise<void> {
|
||||||
|
const caps = (await getCapabilitiesPath("/sys/mounts/" + this.state.baseMount)).capabilities;
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
|
{caps.includes("create") && (
|
||||||
<button
|
<button
|
||||||
class="uk-button uk-button-primary"
|
class="uk-button uk-button-primary"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
@ -135,7 +139,8 @@ export class KeyValueViewPage extends Page {
|
||||||
>
|
>
|
||||||
{i18next.t("kv_view_new_btn")}
|
{i18next.t("kv_view_new_btn")}
|
||||||
</button>
|
</button>
|
||||||
{this.state.secretPath.length == 0 && (
|
)}
|
||||||
|
{this.state.secretPath.length == 0 && caps.includes("delete") && (
|
||||||
<button
|
<button
|
||||||
class="uk-button uk-button-danger"
|
class="uk-button uk-button-danger"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
|
|
@ -79,9 +79,13 @@ export class TOTPViewPage extends Page {
|
||||||
|
|
||||||
async render(): Promise<void> {
|
async render(): Promise<void> {
|
||||||
this.state.secretItem = "";
|
this.state.secretItem = "";
|
||||||
|
|
||||||
|
const caps = (await getCapabilitiesPath("/sys/mounts/" + this.state.baseMount)).capabilities;
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
|
{caps.includes("create") && (
|
||||||
<button
|
<button
|
||||||
class="uk-button uk-button-primary"
|
class="uk-button uk-button-primary"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
@ -90,6 +94,8 @@ export class TOTPViewPage extends Page {
|
||||||
>
|
>
|
||||||
{i18next.t("totp_view_new_btn")}
|
{i18next.t("totp_view_new_btn")}
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
|
{caps.includes("delete") && (
|
||||||
<button
|
<button
|
||||||
class="uk-button uk-button-danger"
|
class="uk-button uk-button-danger"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
@ -98,6 +104,7 @@ export class TOTPViewPage extends Page {
|
||||||
>
|
>
|
||||||
{i18next.t("totp_view_delete_btn")}
|
{i18next.t("totp_view_delete_btn")}
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
</p>
|
</p>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { Component, JSX, render } from "preact";
|
import { Component, JSX, render } from "preact";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
|
import { getCapabilitiesPath } from "../../../api/sys/getCapabilities";
|
||||||
import { getTransitKeys } from "../../../api/transit/getTransitKeys";
|
import { getTransitKeys } from "../../../api/transit/getTransitKeys";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
||||||
|
@ -79,9 +80,13 @@ export class TransitViewPage extends Page {
|
||||||
|
|
||||||
async render(): Promise<void> {
|
async render(): Promise<void> {
|
||||||
this.state.secretItem = "";
|
this.state.secretItem = "";
|
||||||
|
|
||||||
|
const caps = (await getCapabilitiesPath("/sys/mounts/" + this.state.baseMount)).capabilities;
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
|
{caps.includes("create") && (
|
||||||
<button
|
<button
|
||||||
class="uk-button uk-button-primary"
|
class="uk-button uk-button-primary"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
@ -90,6 +95,8 @@ export class TransitViewPage extends Page {
|
||||||
>
|
>
|
||||||
{i18next.t("transit_view_new_btn")}
|
{i18next.t("transit_view_new_btn")}
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
|
{caps.includes("delete") && (
|
||||||
<button
|
<button
|
||||||
class="uk-button uk-button-danger"
|
class="uk-button uk-button-danger"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
@ -98,6 +105,7 @@ export class TransitViewPage extends Page {
|
||||||
>
|
>
|
||||||
{i18next.t("transit_view_delete_btn")}
|
{i18next.t("transit_view_delete_btn")}
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
</p>
|
</p>
|
||||||
<TransitViewListItem page={this} />
|
<TransitViewListItem page={this} />
|
||||||
</>,
|
</>,
|
||||||
|
|
Loading…
Reference in a new issue