Add policies home.
This commit is contained in:
parent
df35a952d1
commit
81ad4346d7
|
@ -21,6 +21,7 @@ import { NewTOTPEnginePage } from "./pages/Secrets/NewEngines/NewTOTPEngine";
|
||||||
import { NewTransitEnginePage } from "./pages/Secrets/NewEngines/NewTransitEngine";
|
import { NewTransitEnginePage } from "./pages/Secrets/NewEngines/NewTransitEngine";
|
||||||
import { NewTransitKeyPage } from "./pages/Secrets/Transit/NewTransitKey";
|
import { NewTransitKeyPage } from "./pages/Secrets/Transit/NewTransitKey";
|
||||||
import { Page } from "./types/Page";
|
import { Page } from "./types/Page";
|
||||||
|
import { PoliciesHomePage } from "./pages/Policies/PoliciesHome";
|
||||||
import { PwGenPage } from "./pages/PwGen";
|
import { PwGenPage } from "./pages/PwGen";
|
||||||
import { SecretsHomePage } from "./pages/Secrets/SecretsHome";
|
import { SecretsHomePage } from "./pages/Secrets/SecretsHome";
|
||||||
import { SetLanguagePage } from "./pages/SetLanguage";
|
import { SetLanguagePage } from "./pages/SetLanguage";
|
||||||
|
@ -47,36 +48,46 @@ type pagesList = {
|
||||||
|
|
||||||
export const allPages: pagesList = {
|
export const allPages: pagesList = {
|
||||||
HOME: new HomePage(),
|
HOME: new HomePage(),
|
||||||
SECRETS_HOME: new SecretsHomePage(),
|
LOGIN: new LoginPage(),
|
||||||
|
SET_VAULT_URL: new SetVaultURLPage(),
|
||||||
|
UNSEAL: new UnsealPage(),
|
||||||
|
SET_LANGUAGE: new SetLanguagePage(),
|
||||||
|
ME: new MePage(),
|
||||||
|
PW_GEN: new PwGenPage(),
|
||||||
|
|
||||||
|
POLICIES_HOME: new PoliciesHomePage(),
|
||||||
|
|
||||||
ACCESS_HOME: new AccessHomePage(),
|
ACCESS_HOME: new AccessHomePage(),
|
||||||
|
|
||||||
AUTH_HOME: new AuthHomePage(),
|
AUTH_HOME: new AuthHomePage(),
|
||||||
AUTH_VIEW_CONFIG: new AuthViewConfigPage(),
|
AUTH_VIEW_CONFIG: new AuthViewConfigPage(),
|
||||||
|
|
||||||
USERPASS_USERS_LIST: new UserPassUsersListPage(),
|
USERPASS_USERS_LIST: new UserPassUsersListPage(),
|
||||||
USERPASS_USER_VIEW: new UserPassUserViewPage(),
|
USERPASS_USER_VIEW: new UserPassUserViewPage(),
|
||||||
USERPASS_USER_EDIT: new UserPassUserEditPage(),
|
USERPASS_USER_EDIT: new UserPassUserEditPage(),
|
||||||
USERPASS_USER_NEW: new UserPassUserNewPage(),
|
USERPASS_USER_NEW: new UserPassUserNewPage(),
|
||||||
USERPASS_USER_DELETE: new UserPassUserDeletePage(),
|
USERPASS_USER_DELETE: new UserPassUserDeletePage(),
|
||||||
ME: new MePage(),
|
|
||||||
|
SECRETS_HOME: new SecretsHomePage(),
|
||||||
|
|
||||||
TOTP_VIEW: new TOTPViewPage(),
|
TOTP_VIEW: new TOTPViewPage(),
|
||||||
TOTP_NEW: new TOTPNewPage(),
|
TOTP_NEW: new TOTPNewPage(),
|
||||||
TOTP_DELETE: new TOTPDeletePage(),
|
TOTP_DELETE: new TOTPDeletePage(),
|
||||||
LOGIN: new LoginPage(),
|
|
||||||
SET_VAULT_URL: new SetVaultURLPage(),
|
|
||||||
UNSEAL: new UnsealPage(),
|
|
||||||
SET_LANGUAGE: new SetLanguagePage(),
|
|
||||||
TRANSIT_NEW_KEY: new NewTransitKeyPage(),
|
|
||||||
TRANSIT_VIEW: new TransitViewPage(),
|
TRANSIT_VIEW: new TransitViewPage(),
|
||||||
|
TRANSIT_NEW_KEY: new NewTransitKeyPage(),
|
||||||
TRANSIT_VIEW_SECRET: new TransitViewSecretPage(),
|
TRANSIT_VIEW_SECRET: new TransitViewSecretPage(),
|
||||||
TRANSIT_ENCRYPT: new TransitEncryptPage(),
|
TRANSIT_ENCRYPT: new TransitEncryptPage(),
|
||||||
TRANSIT_DECRYPT: new TransitDecryptPage(),
|
TRANSIT_DECRYPT: new TransitDecryptPage(),
|
||||||
TRANSIT_REWRAP: new TransitRewrapPage(),
|
TRANSIT_REWRAP: new TransitRewrapPage(),
|
||||||
|
|
||||||
KEY_VALUE_VIEW: new KeyValueViewPage(),
|
KEY_VALUE_VIEW: new KeyValueViewPage(),
|
||||||
KEY_VALUE_SECRET: new KeyValueSecretPage(),
|
KEY_VALUE_SECRET: new KeyValueSecretPage(),
|
||||||
KEY_VALUE_VERSIONS: new KeyValueVersionsPage(),
|
KEY_VALUE_VERSIONS: new KeyValueVersionsPage(),
|
||||||
KEY_VALUE_NEW_SECRET: new KeyValueNewPage(),
|
KEY_VALUE_NEW_SECRET: new KeyValueNewPage(),
|
||||||
KEY_VALUE_DELETE: new KeyValueDeletePage(),
|
KEY_VALUE_DELETE: new KeyValueDeletePage(),
|
||||||
KEY_VALUE_SECRET_EDIT: new KeyValueSecretEditPage(),
|
KEY_VALUE_SECRET_EDIT: new KeyValueSecretEditPage(),
|
||||||
PW_GEN: new PwGenPage(),
|
|
||||||
NEW_SECRETS_ENGINE: new NewSecretsEnginePage(),
|
NEW_SECRETS_ENGINE: new NewSecretsEnginePage(),
|
||||||
NEW_KV_ENGINE: new NewKVEnginePage(),
|
NEW_KV_ENGINE: new NewKVEnginePage(),
|
||||||
NEW_TOTP_ENGINE: new NewTOTPEnginePage(),
|
NEW_TOTP_ENGINE: new NewTOTPEnginePage(),
|
||||||
|
|
10
src/api/sys/getPolicies.ts
Normal file
10
src/api/sys/getPolicies.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||||
|
|
||||||
|
export async function getPolicies(): Promise<string[]> {
|
||||||
|
const request = new Request(appendAPIURL("/v1/sys/policies/acl?list=true"), {
|
||||||
|
headers: getHeaders(),
|
||||||
|
});
|
||||||
|
const response = await fetch(request);
|
||||||
|
const data = (await response.json()) as { data: { keys: string[] } };
|
||||||
|
return data.data.keys;
|
||||||
|
}
|
|
@ -74,6 +74,14 @@ export class HomePage extends Page {
|
||||||
await this.router.changePage("ACCESS_HOME");
|
await this.router.changePage("ACCESS_HOME");
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<Tile
|
||||||
|
title={i18next.t("home_policies_title")}
|
||||||
|
description={i18next.t("home_policies_description")}
|
||||||
|
icon="pencil"
|
||||||
|
onclick={async () => {
|
||||||
|
await this.router.changePage("POLICIES_HOME");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Margin>
|
</Margin>
|
||||||
</div>,
|
</div>,
|
||||||
|
|
50
src/pages/Policies/PoliciesHome.tsx
Normal file
50
src/pages/Policies/PoliciesHome.tsx
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
import { Margin } from "../../elements/Margin";
|
||||||
|
import { Page } from "../../types/Page";
|
||||||
|
import { getPolicies } from "../../api/sys/getPolicies";
|
||||||
|
import { notImplemented, prePageChecks } from "../../pageUtils";
|
||||||
|
import { render } from "preact";
|
||||||
|
import i18next from "i18next";
|
||||||
|
|
||||||
|
export class PoliciesHomePage extends Page {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
async goBack(): Promise<void> {
|
||||||
|
await this.router.changePage("HOME");
|
||||||
|
}
|
||||||
|
async render(): Promise<void> {
|
||||||
|
await this.router.setPageContent("");
|
||||||
|
if (!(await prePageChecks(this.router))) return;
|
||||||
|
|
||||||
|
let policies = await getPolicies();
|
||||||
|
policies = policies.sort();
|
||||||
|
policies = policies.filter(function (policy_name) {
|
||||||
|
return policy_name !== "root";
|
||||||
|
});
|
||||||
|
|
||||||
|
render(
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
<button class="uk-button uk-button-primary" onClick={notImplemented}>
|
||||||
|
{i18next.t("policies_home_new_btn")}
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<Margin>
|
||||||
|
<ul class="uk-nav uk-nav-default">
|
||||||
|
{policies.map((policy: string) => (
|
||||||
|
<li>
|
||||||
|
<a onClick={notImplemented}>{policy}</a>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</Margin>
|
||||||
|
</div>,
|
||||||
|
this.router.pageContentElement,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get name(): string {
|
||||||
|
return i18next.t("policies_home_title");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { JSX, render } from "preact";
|
||||||
import { MountType, getMounts } from "../../api/sys/getMounts";
|
import { MountType, getMounts } from "../../api/sys/getMounts";
|
||||||
import { Page } from "../../types/Page";
|
import { Page } from "../../types/Page";
|
||||||
import { getCapabilitiesPath } from "../../api/sys/getCapabilities";
|
import { getCapabilitiesPath } from "../../api/sys/getCapabilities";
|
||||||
|
@ -5,8 +6,6 @@ import { prePageChecks } from "../../pageUtils";
|
||||||
import { sortedObjectMap } from "../../utils";
|
import { sortedObjectMap } from "../../utils";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
||||||
import { JSX, render } from "preact";
|
|
||||||
|
|
||||||
export type MountLinkProps = {
|
export type MountLinkProps = {
|
||||||
page: Page;
|
page: Page;
|
||||||
mount: MountType;
|
mount: MountType;
|
||||||
|
@ -112,28 +111,6 @@ export class SecretsHomePage extends Page {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async renderPageTitle(): Promise<void> {
|
|
||||||
render(
|
|
||||||
<div>
|
|
||||||
<a
|
|
||||||
onClick={async () => {
|
|
||||||
await this.router.changePage("HOME");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{"/ "}
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
onClick={async () => {
|
|
||||||
await this.router.changePage("HOME");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{"secrets/ "}
|
|
||||||
</a>
|
|
||||||
</div>,
|
|
||||||
this.router.pageTitleElement,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
get name(): string {
|
get name(): string {
|
||||||
return i18next.t("secrets_home_page_title");
|
return i18next.t("secrets_home_page_title");
|
||||||
}
|
}
|
||||||
|
|
6
src/translations/en.js
vendored
6
src/translations/en.js
vendored
|
@ -45,6 +45,8 @@ module.exports = {
|
||||||
home_secrets_description: "View, create and manage secrets.",
|
home_secrets_description: "View, create and manage secrets.",
|
||||||
home_access_title: "Access",
|
home_access_title: "Access",
|
||||||
home_access_description: "Manage who and what has access to vault and how they can authenticate.",
|
home_access_description: "Manage who and what has access to vault and how they can authenticate.",
|
||||||
|
home_policies_title: "Policies",
|
||||||
|
home_policies_description: "Manage policies and permissions.",
|
||||||
|
|
||||||
// Secrets Home Page
|
// Secrets Home Page
|
||||||
secrets_home_page_title: "Secrets",
|
secrets_home_page_title: "Secrets",
|
||||||
|
@ -286,4 +288,8 @@ module.exports = {
|
||||||
userpass_user_delete_text:
|
userpass_user_delete_text:
|
||||||
"Are you sure you want to delete this user? This action can't be reversed.",
|
"Are you sure you want to delete this user? This action can't be reversed.",
|
||||||
userpass_user_delete_btn: "Delete User",
|
userpass_user_delete_btn: "Delete User",
|
||||||
|
|
||||||
|
// Policies Home
|
||||||
|
policies_home_title: "Policies",
|
||||||
|
policies_home_new_btn: "New",
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue