Add UserPassUsersListPage.
This commit is contained in:
parent
2cad885975
commit
555825787c
|
@ -1,3 +1,4 @@
|
||||||
|
import { AccessHomePage } from "./pages/Access/AccessHome";
|
||||||
import { HomePage } from "./pages/Home";
|
import { HomePage } from "./pages/Home";
|
||||||
import { KeyValueDeletePage } from "./pages/Secrets/KeyValue/KeyValueDelete";
|
import { KeyValueDeletePage } from "./pages/Secrets/KeyValue/KeyValueDelete";
|
||||||
import { KeyValueNewPage } from "./pages/Secrets/KeyValue/KeyValueNew";
|
import { KeyValueNewPage } from "./pages/Secrets/KeyValue/KeyValueNew";
|
||||||
|
@ -26,13 +27,12 @@ import { TransitViewPage } from "./pages/Secrets/Transit/TransitView";
|
||||||
import { TransitViewSecretPage } from "./pages/Secrets/Transit/TransitViewSecret";
|
import { TransitViewSecretPage } from "./pages/Secrets/Transit/TransitViewSecret";
|
||||||
import { UnsealPage } from "./pages/Unseal";
|
import { UnsealPage } from "./pages/Unseal";
|
||||||
import { getObjectKeys } from "./utils";
|
import { getObjectKeys } from "./utils";
|
||||||
import { AccessHomePage } from "./pages/Access/AccessHome";
|
|
||||||
|
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
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";
|
import { AuthViewConfigPage } from "./pages/Access/Auth/AuthViewConfig";
|
||||||
|
import { PageType } from "z-pagerouter";
|
||||||
|
import { UserPassUsersListPage } from "./pages/Access/Auth/userpass/UserPassUsersList";
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
|
|
||||||
type pagesList = {
|
type pagesList = {
|
||||||
|
@ -45,6 +45,7 @@ export const allPages: pagesList = {
|
||||||
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(),
|
||||||
ME: new MePage(),
|
ME: new MePage(),
|
||||||
TOTP: new TOTPViewPage(),
|
TOTP: new TOTPViewPage(),
|
||||||
NEW_TOTP: new NewTOTPPage(),
|
NEW_TOTP: new NewTOTPPage(),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { appendAPIURL, getHeaders } from "../apiUtils";
|
|
||||||
import { AuthListAPIType, AuthListType } from "../types/auth";
|
import { AuthListAPIType, AuthListType } from "../types/auth";
|
||||||
|
import { appendAPIURL, getHeaders } from "../apiUtils";
|
||||||
|
|
||||||
export async function listAuth(): Promise<AuthListType> {
|
export async function listAuth(): Promise<AuthListType> {
|
||||||
const request = new Request(appendAPIURL(`/v1/sys/auth`), {
|
const request = new Request(appendAPIURL(`/v1/sys/auth`), {
|
||||||
|
|
10
src/api/auth/userpass/listUserPassUsers.ts
Normal file
10
src/api/auth/userpass/listUserPassUsers.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import { appendAPIURL, getHeaders } from "../../apiUtils";
|
||||||
|
|
||||||
|
export async function listUserPassUsers(path: string): Promise<string[]> {
|
||||||
|
const request = new Request(appendAPIURL(`/v1/auth/${path}/users?list=true`), {
|
||||||
|
headers: getHeaders(),
|
||||||
|
});
|
||||||
|
const resp = await fetch(request);
|
||||||
|
const data = (await resp.json()) as { data: { keys: string[] } };
|
||||||
|
return data.data.keys;
|
||||||
|
}
|
|
@ -3,17 +3,17 @@ export type AuthMethod = {
|
||||||
accessor: string;
|
accessor: string;
|
||||||
config: Record<string, unknown>;
|
config: Record<string, unknown>;
|
||||||
description: string;
|
description: string;
|
||||||
external_entropy_access: Boolean;
|
external_entropy_access: boolean;
|
||||||
local: Boolean;
|
local: boolean;
|
||||||
options: Record<string, unknown>;
|
options: Record<string, unknown>;
|
||||||
seal_wrap: Boolean;
|
seal_wrap: boolean;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type AuthListAPIType = {
|
export type AuthListAPIType = {
|
||||||
data: AuthListType;
|
data: AuthListType;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type AuthListType = {
|
export type AuthListType = {
|
||||||
[path: string]: AuthMethod;
|
[path: string]: AuthMethod;
|
||||||
}
|
};
|
||||||
|
|
|
@ -76,3 +76,7 @@ export function setErrorText(text: string): void {
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function notImplemented(): void {
|
||||||
|
setErrorText(i18next.t("not_implemented"));
|
||||||
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Page } from "../../types/Page";
|
import { Page } from "../../types/Page";
|
||||||
|
import { Tile } from "../../elements/Tile";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
import { prePageChecks, setErrorText } from "../../pageUtils";
|
import { prePageChecks, setErrorText } from "../../pageUtils";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { Tile } from "../../elements/Tile";
|
|
||||||
|
|
||||||
export class AccessHomePage extends Page {
|
export class AccessHomePage extends Page {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -15,7 +15,7 @@ export class AccessHomePage extends Page {
|
||||||
await this.router.setPageContent("");
|
await this.router.setPageContent("");
|
||||||
if (!(await prePageChecks(this.router))) return;
|
if (!(await prePageChecks(this.router))) return;
|
||||||
|
|
||||||
this.router.setPageContent(
|
await this.router.setPageContent(
|
||||||
makeElement({
|
makeElement({
|
||||||
tag: "div",
|
tag: "div",
|
||||||
class: "uk-child-width-1-1@s uk-child-width-1-2@m uk-grid-small uk-grid-match",
|
class: "uk-child-width-1-1@s uk-child-width-1-2@m uk-grid-small uk-grid-match",
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
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 { AuthMethod } from "../../../api/types/auth";
|
||||||
|
import { Page } from "../../../types/Page";
|
||||||
|
import { listAuth } from "../../../api/auth/listAuth";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
|
import { objectToMap } from "../../../utils";
|
||||||
|
import i18next from "i18next";
|
||||||
|
|
||||||
export function AuthListElement(page: Page, path: string, method: AuthMethod): HTMLElement {
|
export function AuthListElement(page: Page, path: string, method: AuthMethod): HTMLElement {
|
||||||
const isClickable = method.type != "token";
|
const isClickable = method.type != "token";
|
||||||
|
@ -16,11 +16,17 @@ export function AuthListElement(page: Page, path: string, method: AuthMethod): H
|
||||||
tag: isClickable ? "a" : "span",
|
tag: isClickable ? "a" : "span",
|
||||||
class: "uk-h4 uk-margin-bottom",
|
class: "uk-h4 uk-margin-bottom",
|
||||||
text: path,
|
text: path,
|
||||||
|
onclick: async () => {
|
||||||
|
page.state.currentBaseMount = path;
|
||||||
|
if (method.type == "userpass") {
|
||||||
|
await page.router.changePage("USERPASS_USERS_LIST");
|
||||||
|
}
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
makeElement({
|
makeElement({
|
||||||
tag: "span",
|
tag: "span",
|
||||||
class: "uk-text-muted",
|
class: "uk-text-muted",
|
||||||
text: ` (${method.accessor})`
|
text: ` (${method.accessor})`,
|
||||||
}),
|
}),
|
||||||
makeElement({
|
makeElement({
|
||||||
tag: "div",
|
tag: "div",
|
||||||
|
@ -40,7 +46,7 @@ export function AuthListElement(page: Page, path: string, method: AuthMethod): H
|
||||||
class: "uk-button uk-button-small uk-button-primary",
|
class: "uk-button uk-button-small uk-button-primary",
|
||||||
text: i18next.t("auth_home_edit_config"),
|
text: i18next.t("auth_home_edit_config"),
|
||||||
}),
|
}),
|
||||||
]
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
@ -56,11 +62,11 @@ export class AuthHomePage extends Page {
|
||||||
async render(): Promise<void> {
|
async render(): Promise<void> {
|
||||||
this.state.currentSecretPath = [];
|
this.state.currentSecretPath = [];
|
||||||
|
|
||||||
let authList = objectToMap(await listAuth()) as Map<string, AuthMethod>;
|
const authList = objectToMap(await listAuth()) as Map<string, AuthMethod>;
|
||||||
const contentElement = makeElement({ tag: "div" });
|
const contentElement = makeElement({ tag: "div" });
|
||||||
this.router.setPageContent(contentElement);
|
await this.router.setPageContent(contentElement);
|
||||||
for (const [path, details] of authList) {
|
for (const [path, details] of authList) {
|
||||||
contentElement.appendChild(AuthListElement(this, path, details))
|
contentElement.appendChild(AuthListElement(this, path, details));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get name(): string {
|
get name(): string {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
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 { AuthMethod } from "../../../api/types/auth";
|
||||||
|
import { Page } from "../../../types/Page";
|
||||||
|
import { listAuth } from "../../../api/auth/listAuth";
|
||||||
import { makeElement } from "z-makeelement";
|
import { makeElement } from "z-makeelement";
|
||||||
|
import { objectToMap } from "../../../utils";
|
||||||
|
import i18next from "i18next";
|
||||||
|
|
||||||
export function HeaderAndContent(title: string, content: string): HTMLElement {
|
export function HeaderAndContent(title: string, content: string): HTMLElement {
|
||||||
return makeElement({
|
return makeElement({
|
||||||
|
@ -14,7 +14,7 @@ export function HeaderAndContent(title: string, content: string): HTMLElement {
|
||||||
children: makeElement({
|
children: makeElement({
|
||||||
tag: "h5",
|
tag: "h5",
|
||||||
text: title,
|
text: title,
|
||||||
})
|
}),
|
||||||
}),
|
}),
|
||||||
makeElement({
|
makeElement({
|
||||||
tag: "td",
|
tag: "td",
|
||||||
|
@ -23,11 +23,10 @@ export function HeaderAndContent(title: string, content: string): HTMLElement {
|
||||||
text: content,
|
text: content,
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
]
|
],
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class AuthViewConfigPage extends Page {
|
export class AuthViewConfigPage extends Page {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -41,42 +40,35 @@ export class AuthViewConfigPage extends Page {
|
||||||
tag: "table",
|
tag: "table",
|
||||||
class: "uk-table",
|
class: "uk-table",
|
||||||
});
|
});
|
||||||
this.router.setPageContent(tableElement);
|
await this.router.setPageContent(tableElement);
|
||||||
const contentElement = makeElement({ tag: "tbody" });
|
const contentElement = makeElement({ tag: "tbody" });
|
||||||
tableElement.appendChild(contentElement);
|
tableElement.appendChild(contentElement);
|
||||||
|
|
||||||
let authList = objectToMap(await listAuth()) as Map<string, AuthMethod>;
|
const authList = objectToMap(await listAuth()) as Map<string, AuthMethod>;
|
||||||
let authMethod = authList.get(this.state.currentBaseMount);
|
const 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(
|
contentElement.appendChild(
|
||||||
HeaderAndContent("Type", authMethod.type)
|
HeaderAndContent("Seal Wrap", String(authMethod.seal_wrap).toString()),
|
||||||
);
|
);
|
||||||
contentElement.appendChild(
|
contentElement.appendChild(
|
||||||
HeaderAndContent("Path", this.state.currentBaseMount)
|
HeaderAndContent(
|
||||||
|
"List when unauthenticated?",
|
||||||
|
String(authMethod.config.listing_visibility).toString(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
contentElement.appendChild(
|
contentElement.appendChild(
|
||||||
HeaderAndContent("Description", authMethod.description)
|
HeaderAndContent("Default Lease TTL", String(authMethod.config.default_lease_ttl).toString()),
|
||||||
);
|
);
|
||||||
contentElement.appendChild(
|
contentElement.appendChild(
|
||||||
HeaderAndContent("Accessor", authMethod.accessor)
|
HeaderAndContent("Max Lease TTL", String(authMethod.config.max_lease_ttl).toString()),
|
||||||
);
|
);
|
||||||
contentElement.appendChild(
|
contentElement.appendChild(
|
||||||
HeaderAndContent("Local", String(authMethod.local).toString())
|
HeaderAndContent("Token Type", authMethod.config.token_type as string),
|
||||||
);
|
|
||||||
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)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
42
src/pages/Access/Auth/userpass/UserPassUsersList.ts
Normal file
42
src/pages/Access/Auth/userpass/UserPassUsersList.ts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import { Page } from "../../../../types/Page";
|
||||||
|
import { listUserPassUsers } from "../../../../api/auth/userpass/listUserPassUsers";
|
||||||
|
import { makeElement } from "z-makeelement";
|
||||||
|
import { notImplemented } from "../../../../pageUtils";
|
||||||
|
import i18next from "i18next";
|
||||||
|
|
||||||
|
export class UserPassUsersListPage extends Page {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
async goBack(): Promise<void> {
|
||||||
|
await this.router.changePage("AUTH_HOME");
|
||||||
|
}
|
||||||
|
|
||||||
|
async render(): Promise<void> {
|
||||||
|
const pageContent = makeElement({ tag: "div" });
|
||||||
|
await this.router.setPageContent(pageContent);
|
||||||
|
|
||||||
|
const users = await listUserPassUsers(this.state.currentBaseMount);
|
||||||
|
pageContent.appendChild(
|
||||||
|
makeElement({
|
||||||
|
tag: "ul",
|
||||||
|
children: [
|
||||||
|
...users.map((user) => {
|
||||||
|
return makeElement({
|
||||||
|
tag: "li",
|
||||||
|
children: makeElement({
|
||||||
|
tag: "a",
|
||||||
|
text: user,
|
||||||
|
onclick: notImplemented,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get name(): string {
|
||||||
|
return i18next.t("userpass_users_list_title");
|
||||||
|
}
|
||||||
|
}
|
3
src/translations/en.js
vendored
3
src/translations/en.js
vendored
|
@ -226,4 +226,7 @@ module.exports = {
|
||||||
// Auth View Conig Page
|
// Auth View Conig Page
|
||||||
auth_view_config_title: "Auth View Config",
|
auth_view_config_title: "Auth View Config",
|
||||||
auth_view_config_suffix: " (view config)",
|
auth_view_config_suffix: " (view config)",
|
||||||
|
|
||||||
|
// userpass Users List
|
||||||
|
userpass_users_list_title: "Users List",
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue