From 46e0571ed023664c8885356884258c9f1f150ee6 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 4 Apr 2021 00:28:51 +0200 Subject: [PATCH] web/admin: only show http basic fields for proxy provider when enabled Signed-off-by: Jens Langhammer --- web/src/pages/providers/ProviderListPage.ts | 4 +- .../providers/proxy/ProxyProviderForm.ts | 41 +++++++++++++------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/web/src/pages/providers/ProviderListPage.ts b/web/src/pages/providers/ProviderListPage.ts index 5d29fcd30..8a2d94a7c 100644 --- a/web/src/pages/providers/ProviderListPage.ts +++ b/web/src/pages/providers/ProviderListPage.ts @@ -61,10 +61,10 @@ export class ProviderListPage extends TablePage { ${item.name} `, item.assignedApplicationName ? - html` + html` ${t`Assigned to application `} ${item.assignedApplicationName}` : - html` + html` ${t`Warning: Provider not assigned to any application.`}`, html`${item.verboseName}`, html` diff --git a/web/src/pages/providers/proxy/ProxyProviderForm.ts b/web/src/pages/providers/proxy/ProxyProviderForm.ts index e3e990070..1128c5d6c 100644 --- a/web/src/pages/providers/proxy/ProxyProviderForm.ts +++ b/web/src/pages/providers/proxy/ProxyProviderForm.ts @@ -18,12 +18,16 @@ export class ProxyProviderFormPage extends Form { id: value, }).then(provider => { this.provider = provider; + this.showHttpBasic = first(provider.basicAuthEnabled, true); }); } @property({attribute: false}) provider?: ProxyProvider; + @property({type: Boolean}) + showHttpBasic = true; + getSuccessMessage(): string { if (this.provider) { return t`Successfully updated provider.`; @@ -45,6 +49,24 @@ export class ProxyProviderFormPage extends Form { } }; + renderHttpBasic(): TemplateResult { + if (!this.showHttpBasic) { + return html``; + } + return html` + +

${t`User/Group Attribute used for the user part of the HTTP-Basic Header. If not set, the user's Email address is used.`}

+
+ + +

${t`User/Group Attribute used for the password part of the HTTP-Basic Header.`}

+
`; + } + renderForm(): TemplateResult { return html`
{ ${t`Advanced protocol settings`} +
@@ -127,25 +150,17 @@ export class ProxyProviderFormPage extends Form {
- + { + const el = ev.target as HTMLInputElement; + this.showHttpBasic = el.checked; + }}>

${t`Set a custom HTTP-Basic Authentication header based on values from authentik.`}

- - -

${t`User/Group Attribute used for the user part of the HTTP-Basic Header. If not set, the user's Email address is used.`}

-
- - -

${t`User/Group Attribute used for the password part of the HTTP-Basic Header.`}

-
+ ${this.renderHttpBasic()}
`;