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 { Form } from "../../../elements/forms/Form"; 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 Form { set providerUUID(value: number) { new ProvidersApi(DEFAULT_CONFIG).providersProxyRead({ 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.`; } else { return t`Successfully created provider.`; } } send = (data: ProxyProvider): Promise => { if (this.provider) { return new ProvidersApi(DEFAULT_CONFIG).providersProxyUpdate({ id: this.provider.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.`}

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

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

${t`Protocol settings`}

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

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

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

${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()}
`; } }