diff --git a/authentik/providers/proxy/models.py b/authentik/providers/proxy/models.py index 76392819d..fb19ba201 100644 --- a/authentik/providers/proxy/models.py +++ b/authentik/providers/proxy/models.py @@ -6,7 +6,6 @@ from urllib.parse import urljoin from django.db import models from django.forms import ModelForm -from django.http import HttpRequest from django.utils.translation import gettext as _ from rest_framework.serializers import Serializer @@ -119,10 +118,6 @@ class ProxyProvider(OutpostModel, OAuth2Provider): """Use external_host as launch URL""" return self.external_host - def html_setup_urls(self, request: HttpRequest) -> Optional[str]: - """Overwrite Setup URLs as they are not needed for proxy""" - return None - def set_oauth_defaults(self): """Ensure all OAuth2-related settings are correct""" self.client_type = ClientTypes.CONFIDENTIAL diff --git a/web/src/api/providers/Proxy.ts b/web/src/api/providers/Proxy.ts new file mode 100644 index 000000000..dad108593 --- /dev/null +++ b/web/src/api/providers/Proxy.ts @@ -0,0 +1,30 @@ +import { DefaultClient } from "../Client"; +import { Provider } from "../Providers"; + +export class ProxyProvider extends Provider { + internal_host: string; + external_host: string; + internal_host_ssl_validation: boolean + certificate?: string; + skip_path_regex: string; + basic_auth_enabled: boolean; + basic_auth_password_attribute: string; + basic_auth_user_attribute: string; + + constructor() { + super(); + throw Error(); + } + + static get(id: number): Promise { + return DefaultClient.fetch(["providers", "proxy", id.toString()]); + } + + static getMetadata(id: number): Promise<{ metadata: string }> { + return DefaultClient.fetch(["providers", "proxy", id.toString(), "metadata"]); + } + + static appUrl(rest: string): string { + return `/application/proxy/${rest}`; + } +} diff --git a/web/src/pages/providers/ProviderViewPage.ts b/web/src/pages/providers/ProviderViewPage.ts index 3f522ab35..133345a30 100644 --- a/web/src/pages/providers/ProviderViewPage.ts +++ b/web/src/pages/providers/ProviderViewPage.ts @@ -8,6 +8,7 @@ import { SpinnerSize } from "../../elements/Spinner"; import "./SAMLProviderViewPage"; import "./OAuth2ProviderViewPage"; +import "./ProxyProviderViewPage"; @customElement("ak-provider-view") export class ProviderViewPage extends LitElement { @@ -45,6 +46,8 @@ export class ProviderViewPage extends LitElement { return html``; case "oauth2": return html``; + case "proxy": + return html``; default: return html`

Invalid provider type ${this.provider?.object_type}

`; } diff --git a/web/src/pages/providers/ProxyProviderViewPage.ts b/web/src/pages/providers/ProxyProviderViewPage.ts new file mode 100644 index 000000000..f827caf2d --- /dev/null +++ b/web/src/pages/providers/ProxyProviderViewPage.ts @@ -0,0 +1,130 @@ +import { gettext } from "django"; +import { CSSResult, customElement, html, property, TemplateResult } from "lit-element"; +import { Provider } from "../../api/Providers"; +import { ProxyProvider } from "../../api/providers/Proxy"; +import { COMMON_STYLES } from "../../common/styles"; + +import "../../elements/buttons/ModalButton"; +import "../../elements/buttons/SpinnerButton"; +import "../../elements/CodeMirror"; +import "../../elements/Tabs"; +import { Page } from "../../elements/Page"; + +@customElement("ak-provider-proxy-view") +export class ProxyProviderViewPage extends Page { + pageTitle(): string { + return gettext(`Proxy Provider ${this.provider?.name}`); + } + pageDescription(): string | undefined { + return; + } + pageIcon(): string { + return "pf-icon pf-icon-integration"; + } + + @property() + set args(value: { [key: string]: number }) { + this.providerID = value.id; + } + + @property({type: Number}) + set providerID(value: number) { + ProxyProvider.get(value).then((app) => (this.provider = app)); + } + + @property({ attribute: false }) + provider?: ProxyProvider; + + static get styles(): CSSResult[] { + return COMMON_STYLES; + } + + constructor() { + super(); + this.addEventListener("ak-refresh", () => { + if (!this.provider?.pk) return; + this.providerID = this.provider?.pk; + }); + } + + renderContent(): TemplateResult { + if (!this.provider) { + return html``; + } + return html` +
+
+
+
+
+
+
+
+ ${gettext("Name")} +
+
+
${this.provider.name}
+
+
+
+
+ ${gettext("Assigned to application")} +
+
+ +
+
+
+
+ ${gettext("Internal Host")} +
+
+
${this.provider.internal_host}
+
+
+
+
+ ${gettext("External Host")} +
+
+
${this.provider.internal_host}
+
+
+
+
+ ${gettext("Basic-Auth")} +
+
+
+ ${this.provider.basic_auth_enabled ? + html` + +  ${gettext("Yes")}`: + html` + +  ${gettext("No")}` + } +
+
+
+
+
+ +
+
+
+
+
`; + } +}