diff --git a/src/allPages.ts b/src/allPages.ts index 9bd7347..970cdde 100644 --- a/src/allPages.ts +++ b/src/allPages.ts @@ -21,6 +21,7 @@ import { NewTOTPEnginePage } from "./pages/Secrets/NewEngines/NewTOTPEngine"; import { NewTransitEnginePage } from "./pages/Secrets/NewEngines/NewTransitEngine"; import { NewTransitKeyPage } from "./pages/Secrets/Transit/NewTransitKey"; import { Page } from "./types/Page"; +import { PoliciesHomePage } from "./pages/Policies/PoliciesHome"; import { PwGenPage } from "./pages/PwGen"; import { SecretsHomePage } from "./pages/Secrets/SecretsHome"; import { SetLanguagePage } from "./pages/SetLanguage"; @@ -47,36 +48,46 @@ type pagesList = { export const allPages: pagesList = { 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(), + AUTH_HOME: new AuthHomePage(), AUTH_VIEW_CONFIG: new AuthViewConfigPage(), + USERPASS_USERS_LIST: new UserPassUsersListPage(), USERPASS_USER_VIEW: new UserPassUserViewPage(), USERPASS_USER_EDIT: new UserPassUserEditPage(), USERPASS_USER_NEW: new UserPassUserNewPage(), USERPASS_USER_DELETE: new UserPassUserDeletePage(), - ME: new MePage(), + + SECRETS_HOME: new SecretsHomePage(), + TOTP_VIEW: new TOTPViewPage(), TOTP_NEW: new TOTPNewPage(), 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_NEW_KEY: new NewTransitKeyPage(), TRANSIT_VIEW_SECRET: new TransitViewSecretPage(), TRANSIT_ENCRYPT: new TransitEncryptPage(), TRANSIT_DECRYPT: new TransitDecryptPage(), TRANSIT_REWRAP: new TransitRewrapPage(), + KEY_VALUE_VIEW: new KeyValueViewPage(), KEY_VALUE_SECRET: new KeyValueSecretPage(), KEY_VALUE_VERSIONS: new KeyValueVersionsPage(), KEY_VALUE_NEW_SECRET: new KeyValueNewPage(), KEY_VALUE_DELETE: new KeyValueDeletePage(), KEY_VALUE_SECRET_EDIT: new KeyValueSecretEditPage(), - PW_GEN: new PwGenPage(), + NEW_SECRETS_ENGINE: new NewSecretsEnginePage(), NEW_KV_ENGINE: new NewKVEnginePage(), NEW_TOTP_ENGINE: new NewTOTPEnginePage(), diff --git a/src/api/sys/getPolicies.ts b/src/api/sys/getPolicies.ts new file mode 100644 index 0000000..5868064 --- /dev/null +++ b/src/api/sys/getPolicies.ts @@ -0,0 +1,10 @@ +import { appendAPIURL, getHeaders } from "../apiUtils"; + +export async function getPolicies(): Promise { + 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; +} diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 8b8e67a..782657d 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -74,6 +74,14 @@ export class HomePage extends Page { await this.router.changePage("ACCESS_HOME"); }} /> + { + await this.router.changePage("POLICIES_HOME"); + }} + /> , diff --git a/src/pages/Policies/PoliciesHome.tsx b/src/pages/Policies/PoliciesHome.tsx new file mode 100644 index 0000000..ebf245a --- /dev/null +++ b/src/pages/Policies/PoliciesHome.tsx @@ -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 { + await this.router.changePage("HOME"); + } + async render(): Promise { + 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( +
+

+ +

+ + +
    + {policies.map((policy: string) => ( +
  • + {policy} +
  • + ))} +
+
+
, + this.router.pageContentElement, + ); + } + + get name(): string { + return i18next.t("policies_home_title"); + } +} diff --git a/src/pages/Secrets/SecretsHome.tsx b/src/pages/Secrets/SecretsHome.tsx index fd93988..345fe4e 100644 --- a/src/pages/Secrets/SecretsHome.tsx +++ b/src/pages/Secrets/SecretsHome.tsx @@ -1,3 +1,4 @@ +import { JSX, render } from "preact"; import { MountType, getMounts } from "../../api/sys/getMounts"; import { Page } from "../../types/Page"; import { getCapabilitiesPath } from "../../api/sys/getCapabilities"; @@ -5,8 +6,6 @@ import { prePageChecks } from "../../pageUtils"; import { sortedObjectMap } from "../../utils"; import i18next from "i18next"; -import { JSX, render } from "preact"; - export type MountLinkProps = { page: Page; mount: MountType; @@ -112,28 +111,6 @@ export class SecretsHomePage extends Page { ); } - async renderPageTitle(): Promise { - render( - , - this.router.pageTitleElement, - ); - } - get name(): string { return i18next.t("secrets_home_page_title"); } diff --git a/src/translations/en.js b/src/translations/en.js index 5e913a0..ece6fd8 100644 --- a/src/translations/en.js +++ b/src/translations/en.js @@ -45,6 +45,8 @@ module.exports = { home_secrets_description: "View, create and manage secrets.", home_access_title: "Access", 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_title: "Secrets", @@ -286,4 +288,8 @@ module.exports = { userpass_user_delete_text: "Are you sure you want to delete this user? This action can't be reversed.", userpass_user_delete_btn: "Delete User", + + // Policies Home + policies_home_title: "Policies", + policies_home_new_btn: "New", };