import "@goauthentik/admin/common/ak-crypto-certificate-search"; import "@goauthentik/admin/common/ak-flow-search/ak-flow-search"; import { oauth2ProviderSelector, oauth2ProvidersProvider, } from "@goauthentik/admin/providers/oauth2/OAuth2ProviderForm"; import { oauth2SourcesProvider, oauth2SourcesSelector, } from "@goauthentik/admin/providers/oauth2/OAuth2Sources.js"; import "@goauthentik/components/ak-toggle-group"; import "@goauthentik/elements/ak-dual-select/ak-dual-select-dynamic-selected-provider.js"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/SearchSelect"; import "@goauthentik/elements/utils/TimeDeltaHelp"; import { match } from "ts-pattern"; import { msg } from "@lit/localize"; import { html, nothing } from "lit"; import { ifDefined } from "lit/directives/if-defined.js"; import { FlowsInstancesListDesignationEnum, ProxyMode, ProxyProvider, ValidationError, } from "@goauthentik/api"; import { propertyMappingsProvider, propertyMappingsSelector } from "./ProxyProviderFormHelpers.js"; export type ProxyModeValue = { value: ProxyMode }; export type SetMode = (ev: CustomEvent) => void; export type SetShowHttpBasic = (ev: Event) => void; export interface ProxyModeExtraArgs { mode: ProxyMode; onSetMode: SetMode; showHttpBasic: boolean; onSetShowHttpBasic: SetShowHttpBasic; } function renderHttpBasic(provider: Partial) { return html` `; } function renderModeSelector(mode: ProxyMode, onSet: SetMode) { // prettier-ignore return html` `; } function renderProxySettings(provider: Partial, errors?: ValidationError) { return html`

${msg( "This provider will behave like a transparent reverse-proxy, except requests must be authenticated. If your upstream application uses HTTPS, make sure to connect to the outpost using HTTPS as well.", )}

`; } function renderForwardSingleSettings(provider: Partial, errors?: ValidationError) { return html`

${msg( "Use this provider with nginx's auth_request or traefik's forwardAuth. Each application/domain needs its own provider. Additionally, on each domain, /outpost.goauthentik.io must be routed to the outpost (when using a managed outpost, this is done for you).", )}

`; } function renderForwardDomainSettings(provider: Partial, errors?: ValidationError) { return html`

${msg( "Use this provider with nginx's auth_request or traefik's forwardAuth. Only a single provider is required per root domain. You can't do per-application authorization, but you don't have to create a provider for each application.", )}

${msg("An example setup can look like this:")}
  • ${msg("authentik running on auth.example.com")}
  • ${msg("app1 running on app1.example.com")}
${msg( "In this case, you'd set the Authentication URL to auth.example.com and Cookie domain to example.com.", )}
`; } type StrictProxyMode = Omit; function renderSettings(provider: Partial, mode: ProxyMode) { return match(mode as StrictProxyMode) .with(ProxyMode.Proxy, () => renderProxySettings(provider)) .with(ProxyMode.ForwardSingle, () => renderForwardSingleSettings(provider)) .with(ProxyMode.ForwardDomain, () => renderForwardDomainSettings(provider)) .otherwise(() => { throw new Error("Unrecognized proxy mode"); }); } export function renderForm( provider: Partial = {}, errors: ValidationError = {}, args: ProxyModeExtraArgs, ) { const { mode, onSetMode, showHttpBasic, onSetShowHttpBasic } = args; return html`

${msg("Flow used when authorizing this provider.")}

${renderModeSelector(mode, onSetMode)}
${msg("Advanced protocol settings")}

${msg("Additional scope mappings, which are passed to the proxy.")}

${msg( "Regular expressions for which authentication is not required. Each new line is interpreted as a new expression.", )}

${msg( "When using proxy or forward auth (single application) mode, the requested URL Path is checked against the regular expressions. When using forward auth (domain mode), the full requested URL including scheme and host is matched against the regular expressions.", )}

${msg("Authentication settings")}
${showHttpBasic ? renderHttpBasic(provider) : nothing}

${msg( "JWTs signed by certificates configured in the selected sources can be used to authenticate to this provider.", )}

${msg( "JWTs signed by the selected providers can be used to authenticate to this provider.", )}

${msg("Advanced flow settings")}

${msg( "Flow used when a user access this provider and is not authenticated.", )}

${msg("Flow used when logging out of this provider.")}

`; }