import { CryptoApi, FlowDesignationEnum, FlowsApi, ProvidersApi, ProxyProvider } from "authentik-api"; import { t } from "@lingui/macro"; import { customElement, property } from "lit-element"; import { html, TemplateResult } from "lit-html"; import { DEFAULT_CONFIG } from "../../../api/Config"; import { ModelForm } from "../../../elements/forms/ModelForm"; import { until } from "lit-html/directives/until"; import { ifDefined } from "lit-html/directives/if-defined"; import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/FormGroup"; import { first } from "../../../utils"; @customElement("ak-provider-proxy-form") export class ProxyProviderFormPage extends ModelForm { loadInstance(pk: number): Promise { return new ProvidersApi(DEFAULT_CONFIG).providersProxyRead({ id: pk, }).then(provider => { this.showHttpBasic = first(provider.basicAuthEnabled, true); this.showInternalServer = first(!provider.forwardAuthMode, true); return provider; }); } @property({type: Boolean}) showHttpBasic = true; @property({type: Boolean}) showInternalServer = true; getSuccessMessage(): string { if (this.instance) { return t`Successfully updated provider.`; } else { return t`Successfully created provider.`; } } send = (data: ProxyProvider): Promise => { if (this.instance) { return new ProvidersApi(DEFAULT_CONFIG).providersProxyUpdate({ id: this.instance.pk || 0, data: data }); } else { return new ProvidersApi(DEFAULT_CONFIG).providersProxyCreate({ data: data }); } }; 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.`}

`; } renderInternalServer(): TemplateResult { if (!this.showInternalServer) { return html``; } return html`

${t`Upstream host that the requests are forwarded to.`}

${t`Validate SSL Certificates of upstream servers.`}

`; } renderForm(): TemplateResult { return html`

${t`Flow used when authorizing this provider.`}

${t`Protocol settings`}

${t`The external URL you'll access the outpost at.`}

{ const el = ev.target as HTMLInputElement; this.showInternalServer = !el.checked; }}>

${t`Enable this if you don't want to use this provider as a proxy, and want to use it with Traefik's forwardAuth or nginx's auth_request.`}

${this.renderInternalServer()}
${t`Advanced protocol settings`}

${t`Regular expressions for which authentication is not required. Each new line is interpreted as a new Regular Expression.`}

{ const el = ev.target as HTMLInputElement; this.showHttpBasic = el.checked; }}>

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

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