Add listing to AuthViewConfigPage.
This commit is contained in:
parent
f72801a687
commit
2cad885975
|
@ -32,6 +32,7 @@ import { AccessHomePage } from "./pages/Access/AccessHome";
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { PageType } from "z-pagerouter";
|
import { PageType } from "z-pagerouter";
|
||||||
import { AuthHomePage } from "./pages/Access/Auth/AuthHome";
|
import { AuthHomePage } from "./pages/Access/Auth/AuthHome";
|
||||||
|
import { AuthViewConfigPage } from "./pages/Access/Auth/AuthViewConfig";
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
|
|
||||||
type pagesList = {
|
type pagesList = {
|
||||||
|
@ -43,6 +44,7 @@ export const allPages: pagesList = {
|
||||||
SECRETS_HOME: new SecretsHomePage(),
|
SECRETS_HOME: new SecretsHomePage(),
|
||||||
ACCESS_HOME: new AccessHomePage(),
|
ACCESS_HOME: new AccessHomePage(),
|
||||||
AUTH_HOME: new AuthHomePage(),
|
AUTH_HOME: new AuthHomePage(),
|
||||||
|
AUTH_VIEW_CONFIG: new AuthViewConfigPage(),
|
||||||
ME: new MePage(),
|
ME: new MePage(),
|
||||||
TOTP: new TOTPViewPage(),
|
TOTP: new TOTPViewPage(),
|
||||||
NEW_TOTP: new NewTOTPPage(),
|
NEW_TOTP: new NewTOTPPage(),
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import { MountType, getMounts } from "../../api/sys/getMounts";
|
|
||||||
import { Page } from "../../types/Page";
|
import { Page } from "../../types/Page";
|
||||||
import { getCapabilitiesPath } from "../../api/sys/getCapabilities";
|
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { prePageChecks, setErrorText } from "../../pageUtils";
|
import { prePageChecks, setErrorText } from "../../pageUtils";
|
||||||
import { sortedObjectMap } from "../../utils";
|
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { Tile } from "../../elements/Tile";
|
import { Tile } from "../../elements/Tile";
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { setErrorText } from "../../../pageUtils";
|
|
||||||
import { listAuth } from "../../../api/auth/listAuth";
|
import { listAuth } from "../../../api/auth/listAuth";
|
||||||
import { objectToMap } from "../../../utils";
|
import { objectToMap } from "../../../utils";
|
||||||
import { AuthMethod } from "../../../api/types/auth";
|
import { AuthMethod } from "../../../api/types/auth";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
|
|
||||||
|
export function AuthListElement(page: Page, path: string, method: AuthMethod): HTMLElement {
|
||||||
export function AuthListElement(path: string, method: AuthMethod): HTMLElement {
|
|
||||||
const isClickable = method.type != "token";
|
const isClickable = method.type != "token";
|
||||||
|
|
||||||
return makeElement({
|
return makeElement({
|
||||||
|
@ -31,16 +29,19 @@ export function AuthListElement(path: string, method: AuthMethod): HTMLElement {
|
||||||
makeElement({
|
makeElement({
|
||||||
tag: "button",
|
tag: "button",
|
||||||
class: "uk-button uk-button-small uk-button-primary",
|
class: "uk-button uk-button-small uk-button-primary",
|
||||||
text: "View Config",
|
text: i18next.t("auth_home_view_config"),
|
||||||
|
onclick: async () => {
|
||||||
|
page.state.currentBaseMount = path;
|
||||||
|
await page.router.changePage("AUTH_VIEW_CONFIG");
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
makeElement({
|
makeElement({
|
||||||
tag: "button",
|
tag: "button",
|
||||||
class: "uk-button uk-button-small uk-button-primary",
|
class: "uk-button uk-button-small uk-button-primary",
|
||||||
text: "Edit Config",
|
text: i18next.t("auth_home_edit_config"),
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -53,11 +54,13 @@ export class AuthHomePage extends Page {
|
||||||
await this.router.changePage("ACCESS_HOME");
|
await this.router.changePage("ACCESS_HOME");
|
||||||
}
|
}
|
||||||
async render(): Promise<void> {
|
async render(): Promise<void> {
|
||||||
|
this.state.currentSecretPath = [];
|
||||||
|
|
||||||
let authList = objectToMap(await listAuth()) as Map<string, AuthMethod>;
|
let authList = objectToMap(await listAuth()) as Map<string, AuthMethod>;
|
||||||
const contentElement = makeElement({ tag: "div" });
|
const contentElement = makeElement({ tag: "div" });
|
||||||
this.router.setPageContent(contentElement);
|
this.router.setPageContent(contentElement);
|
||||||
for (const [path, details] of authList) {
|
for (const [path, details] of authList) {
|
||||||
contentElement.appendChild(AuthListElement(path, details))
|
contentElement.appendChild(AuthListElement(this, path, details))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get name(): string {
|
get name(): string {
|
||||||
|
|
86
src/pages/Access/Auth/AuthViewConfig.ts
Normal file
86
src/pages/Access/Auth/AuthViewConfig.ts
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
import { Page } from "../../../types/Page";
|
||||||
|
import i18next from "i18next";
|
||||||
|
import { listAuth } from "../../../api/auth/listAuth";
|
||||||
|
import { objectToMap } from "../../../utils";
|
||||||
|
import { AuthMethod } from "../../../api/types/auth";
|
||||||
|
import { makeElement } from "z-makeelement";
|
||||||
|
|
||||||
|
export function HeaderAndContent(title: string, content: string): HTMLElement {
|
||||||
|
return makeElement({
|
||||||
|
tag: "tr",
|
||||||
|
children: [
|
||||||
|
makeElement({
|
||||||
|
tag: "td",
|
||||||
|
children: makeElement({
|
||||||
|
tag: "h5",
|
||||||
|
text: title,
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
makeElement({
|
||||||
|
tag: "td",
|
||||||
|
children: makeElement({
|
||||||
|
tag: "p",
|
||||||
|
text: content,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class AuthViewConfigPage extends Page {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
async goBack(): Promise<void> {
|
||||||
|
await this.router.changePage("AUTH_HOME");
|
||||||
|
}
|
||||||
|
|
||||||
|
async render(): Promise<void> {
|
||||||
|
const tableElement = makeElement({
|
||||||
|
tag: "table",
|
||||||
|
class: "uk-table",
|
||||||
|
});
|
||||||
|
this.router.setPageContent(tableElement);
|
||||||
|
const contentElement = makeElement({ tag: "tbody" });
|
||||||
|
tableElement.appendChild(contentElement);
|
||||||
|
|
||||||
|
let authList = objectToMap(await listAuth()) as Map<string, AuthMethod>;
|
||||||
|
let authMethod = authList.get(this.state.currentBaseMount);
|
||||||
|
|
||||||
|
contentElement.appendChild(
|
||||||
|
HeaderAndContent("Type", authMethod.type)
|
||||||
|
);
|
||||||
|
contentElement.appendChild(
|
||||||
|
HeaderAndContent("Path", this.state.currentBaseMount)
|
||||||
|
);
|
||||||
|
contentElement.appendChild(
|
||||||
|
HeaderAndContent("Description", authMethod.description)
|
||||||
|
);
|
||||||
|
contentElement.appendChild(
|
||||||
|
HeaderAndContent("Accessor", authMethod.accessor)
|
||||||
|
);
|
||||||
|
contentElement.appendChild(
|
||||||
|
HeaderAndContent("Local", String(authMethod.local).toString())
|
||||||
|
);
|
||||||
|
contentElement.appendChild(
|
||||||
|
HeaderAndContent("Seal Wrap", String(authMethod.seal_wrap).toString())
|
||||||
|
);
|
||||||
|
contentElement.appendChild(
|
||||||
|
HeaderAndContent("List when unauthenticated?", String(authMethod.config.listing_visibility).toString())
|
||||||
|
);
|
||||||
|
contentElement.appendChild(
|
||||||
|
HeaderAndContent("Default Lease TTL", String(authMethod.config.default_lease_ttl).toString())
|
||||||
|
);
|
||||||
|
contentElement.appendChild(
|
||||||
|
HeaderAndContent("Max Lease TTL", String(authMethod.config.max_lease_ttl).toString())
|
||||||
|
);
|
||||||
|
contentElement.appendChild(
|
||||||
|
HeaderAndContent("Token Type", authMethod.config.token_type as string)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get name(): string {
|
||||||
|
return i18next.t("auth_view_config_title");
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,11 @@ export class HomePage extends Page {
|
||||||
await this.router.setPageContent("");
|
await this.router.setPageContent("");
|
||||||
if (!(await prePageChecks(this.router))) return;
|
if (!(await prePageChecks(this.router))) return;
|
||||||
|
|
||||||
|
this.state.currentBaseMount = "";
|
||||||
|
this.state.currentSecretPath = [];
|
||||||
|
this.state.currentSecret = "";
|
||||||
|
this.state.currentSecretVersion = null;
|
||||||
|
|
||||||
const homePageContent = makeElement({ tag: "div" });
|
const homePageContent = makeElement({ tag: "div" });
|
||||||
await this.router.setPageContent(homePageContent);
|
await this.router.setPageContent(homePageContent);
|
||||||
const textList = makeElement({
|
const textList = makeElement({
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { deleteSecret } from "../../../api/kv/deleteSecret";
|
import { deleteSecret } from "../../../api/kv/deleteSecret";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { createOrUpdateSecret } from "../../../api/kv/createOrUpdateSecret";
|
import { createOrUpdateSecret } from "../../../api/kv/createOrUpdateSecret";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { setErrorText } from "../../../pageUtils";
|
import { setErrorText } from "../../../pageUtils";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CopyableInputBox } from "../../../elements/CopyableInputBox";
|
import { CopyableInputBox } from "../../../elements/CopyableInputBox";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { getCapabilities } from "../../../api/sys/getCapabilities";
|
import { getCapabilities } from "../../../api/sys/getCapabilities";
|
||||||
import { getSecret } from "../../../api/kv/getSecret";
|
import { getSecret } from "../../../api/kv/getSecret";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CodeJar } from "codejar";
|
import { CodeJar } from "codejar";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { createOrUpdateSecret } from "../../../api/kv/createOrUpdateSecret";
|
import { createOrUpdateSecret } from "../../../api/kv/createOrUpdateSecret";
|
||||||
import { getSecret } from "../../../api/kv/getSecret";
|
import { getSecret } from "../../../api/kv/getSecret";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { getSecretMetadata } from "../../../api/kv/getSecretMetadata";
|
import { getSecretMetadata } from "../../../api/kv/getSecretMetadata";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { objectToMap } from "../../../utils";
|
import { objectToMap } from "../../../utils";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { DoesNotExistError } from "../../../types/internalErrors";
|
import { DoesNotExistError } from "../../../types/internalErrors";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { getSecrets } from "../../../api/kv/getSecrets";
|
import { getSecrets } from "../../../api/kv/getSecrets";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { setErrorText } from "../../../pageUtils";
|
import { setErrorText } from "../../../pageUtils";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { PageRouter } from "z-pagerouter";
|
import { PageRouter } from "z-pagerouter";
|
||||||
import { PageState } from "../PageState";
|
import { PageState } from "../../PageState";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
|
|
||||||
function currentTitleSecretText(state: PageState, suffix = ""): string {
|
function currentTitleSecretText(state: PageState, suffix = ""): string {
|
|
@ -1,7 +1,7 @@
|
||||||
import { Margin } from "../../../elements/Margin";
|
import { Margin } from "../../../elements/Margin";
|
||||||
import { MarginInline } from "../../../elements/MarginInline";
|
import { MarginInline } from "../../../elements/MarginInline";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { addNewTOTP } from "../../../api/totp/addNewTOTP";
|
import { addNewTOTP } from "../../../api/totp/addNewTOTP";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { setErrorText } from "../../../pageUtils";
|
import { setErrorText } from "../../../pageUtils";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { CopyableInputBox } from "../../../elements/CopyableInputBox";
|
import { CopyableInputBox } from "../../../elements/CopyableInputBox";
|
||||||
import { DoesNotExistError } from "../../../types/internalErrors";
|
import { DoesNotExistError } from "../../../types/internalErrors";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { getTOTPCode } from "../../../api/totp/getTOTPCode";
|
import { getTOTPCode } from "../../../api/totp/getTOTPCode";
|
||||||
import { getTOTPKeys } from "../../../api/totp/getTOTPKeys";
|
import { getTOTPKeys } from "../../../api/totp/getTOTPKeys";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Margin } from "../../../elements/Margin";
|
import { Margin } from "../../../elements/Margin";
|
||||||
import { Option } from "../../../elements/Option";
|
import { Option } from "../../../elements/Option";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { newTransitKey } from "../../../api/transit/newTransitKey";
|
import { newTransitKey } from "../../../api/transit/newTransitKey";
|
||||||
import { setErrorText } from "../../../pageUtils";
|
import { setErrorText } from "../../../pageUtils";
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { CopyableModal } from "../../../elements/CopyableModal";
|
||||||
import { FileUploadInput } from "../../../elements/FileUploadInput";
|
import { FileUploadInput } from "../../../elements/FileUploadInput";
|
||||||
import { Margin } from "../../../elements/Margin";
|
import { Margin } from "../../../elements/Margin";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { fileToBase64 } from "../../../htmlUtils";
|
import { fileToBase64 } from "../../../htmlUtils";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { setErrorText } from "../../../pageUtils";
|
import { setErrorText } from "../../../pageUtils";
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { CopyableModal } from "../../../elements/CopyableModal";
|
||||||
import { FileUploadInput } from "../../../elements/FileUploadInput";
|
import { FileUploadInput } from "../../../elements/FileUploadInput";
|
||||||
import { Margin } from "../../../elements/Margin";
|
import { Margin } from "../../../elements/Margin";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { fileToBase64 } from "../../../htmlUtils";
|
import { fileToBase64 } from "../../../htmlUtils";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { setErrorText } from "../../../pageUtils";
|
import { setErrorText } from "../../../pageUtils";
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { CopyableModal } from "../../../elements/CopyableModal";
|
||||||
import { Margin } from "../../../elements/Margin";
|
import { Margin } from "../../../elements/Margin";
|
||||||
import { Option } from "../../../elements/Option";
|
import { Option } from "../../../elements/Option";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { getTransitKey } from "../../../api/transit/getTransitKey";
|
import { getTransitKey } from "../../../api/transit/getTransitKey";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { objectToMap } from "../../../utils";
|
import { objectToMap } from "../../../utils";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { DoesNotExistError } from "../../../types/internalErrors";
|
import { DoesNotExistError } from "../../../types/internalErrors";
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { getTransitKeys } from "../../../api/transit/getTransitKeys";
|
import { getTransitKeys } from "../../../api/transit/getTransitKeys";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { setErrorText } from "../../../pageUtils";
|
import { setErrorText } from "../../../pageUtils";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Page } from "../../../types/Page";
|
import { Page } from "../../../types/Page";
|
||||||
import { SecretTitleElement } from "../../../elements/SecretTitleElement";
|
import { SecretTitleElement } from "../SecretTitleElement";
|
||||||
import { Tile } from "../../../elements/Tile";
|
import { Tile } from "../../../elements/Tile";
|
||||||
import { getTransitKey } from "../../../api/transit/getTransitKey";
|
import { getTransitKey } from "../../../api/transit/getTransitKey";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
|
|
4
src/translations/en.js
vendored
4
src/translations/en.js
vendored
|
@ -222,4 +222,8 @@ module.exports = {
|
||||||
auth_home_title: "Auth",
|
auth_home_title: "Auth",
|
||||||
auth_home_view_config: "View Config",
|
auth_home_view_config: "View Config",
|
||||||
auth_home_edit_config: "Edit Config",
|
auth_home_edit_config: "Edit Config",
|
||||||
|
|
||||||
|
// Auth View Conig Page
|
||||||
|
auth_view_config_title: "Auth View Config",
|
||||||
|
auth_view_config_suffix: " (view config)",
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue