diff --git a/internal/web/proxy.go b/internal/web/proxy.go index b606fdef795c..00e6761119b2 100644 --- a/internal/web/proxy.go +++ b/internal/web/proxy.go @@ -13,6 +13,10 @@ import ( "goauthentik.io/internal/utils/sentry" ) +var ( + ErrAuthentikStarting = errors.New("authentik starting") +) + func (ws *WebServer) configureProxy() { // Reverse proxy to the application server director := func(req *http.Request) { @@ -38,7 +42,7 @@ func (ws *WebServer) configureProxy() { })) ws.mainRouter.PathPrefix(config.Get().Web.Path).HandlerFunc(sentry.SentryNoSample(func(rw http.ResponseWriter, r *http.Request) { if !ws.g.IsRunning() { - ws.proxyErrorHandler(rw, r, errors.New("authentik starting")) + ws.proxyErrorHandler(rw, r, ErrAuthentikStarting) return } before := time.Now() @@ -59,7 +63,9 @@ func (ws *WebServer) configureProxy() { } func (ws *WebServer) proxyErrorHandler(rw http.ResponseWriter, req *http.Request, err error) { - ws.log.WithError(err).Warning("failed to proxy to backend") + if !errors.Is(err, ErrAuthentikStarting) { + ws.log.WithError(err).Warning("failed to proxy to backend") + } rw.WriteHeader(http.StatusBadGateway) em := fmt.Sprintf("failed to connect to authentik backend: %v", err) // return json if the client asks for json diff --git a/web/src/admin/AdminInterface/AdminInterface.ts b/web/src/admin/AdminInterface/AdminInterface.ts index 0eb52378495c..4219377c7f7a 100644 --- a/web/src/admin/AdminInterface/AdminInterface.ts +++ b/web/src/admin/AdminInterface/AdminInterface.ts @@ -8,7 +8,7 @@ import { import { configureSentry } from "@goauthentik/common/sentry"; import { me } from "@goauthentik/common/users"; import { WebsocketClient } from "@goauthentik/common/ws"; -import { EnterpriseAwareInterface } from "@goauthentik/elements/Interface"; +import { AuthenticatedInterface } from "@goauthentik/elements/Interface"; import "@goauthentik/elements/ak-locale-context"; import "@goauthentik/elements/enterprise/EnterpriseStatusBanner"; import "@goauthentik/elements/messages/MessageContainer"; @@ -29,12 +29,12 @@ import PFDrawer from "@patternfly/patternfly/components/Drawer/drawer.css"; import PFPage from "@patternfly/patternfly/components/Page/page.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; -import { SessionUser, UiThemeEnum, Version } from "@goauthentik/api"; +import { SessionUser, UiThemeEnum } from "@goauthentik/api"; import "./AdminSidebar"; @customElement("ak-interface-admin") -export class AdminInterface extends EnterpriseAwareInterface { +export class AdminInterface extends AuthenticatedInterface { @property({ type: Boolean }) notificationDrawerOpen = getURLParam("notificationDrawerOpen", false); @@ -43,9 +43,6 @@ export class AdminInterface extends EnterpriseAwareInterface { ws: WebsocketClient; - @state() - version?: Version; - @state() user?: SessionUser; diff --git a/web/src/elements/Interface/EnterpriseContextController.ts b/web/src/elements/Interface/EnterpriseContextController.ts index f0cc1ac2a8e7..8f27a637ba0d 100644 --- a/web/src/elements/Interface/EnterpriseContextController.ts +++ b/web/src/elements/Interface/EnterpriseContextController.ts @@ -9,14 +9,14 @@ import type { ReactiveController } from "lit"; import type { LicenseSummary } from "@goauthentik/api"; import { EnterpriseApi } from "@goauthentik/api"; -import type { AkEnterpriseInterface } from "./Interface"; +import type { AkAuthenticatedInterface } from "./Interface"; export class EnterpriseContextController implements ReactiveController { - host!: ReactiveElementHost; + host!: ReactiveElementHost; context!: ContextProvider<{ __context__: LicenseSummary | undefined }>; - constructor(host: ReactiveElementHost) { + constructor(host: ReactiveElementHost) { this.host = host; this.context = new ContextProvider(this.host, { context: authentikEnterpriseContext, diff --git a/web/src/elements/Interface/Interface.ts b/web/src/elements/Interface/Interface.ts index 418222e28611..fed91b5f11c7 100644 --- a/web/src/elements/Interface/Interface.ts +++ b/web/src/elements/Interface/Interface.ts @@ -20,7 +20,6 @@ export type AkInterface = HTMLElement & { brand?: CurrentBrand; uiConfig?: UIConfig; config?: Config; - version?: Version; }; const brandContext = Symbol("brandContext"); @@ -29,16 +28,14 @@ const modalController = Symbol("modalController"); const versionContext = Symbol("versionContext"); export class Interface extends AKElement implements AkInterface { - @state() - uiConfig?: UIConfig; - [brandContext]!: BrandContextController; [configContext]!: ConfigContextController; [modalController]!: ModalOrchestrationController; - [versionContext]!: VersionContextController; + @state() + uiConfig?: UIConfig; @state() config?: Config; @@ -57,7 +54,6 @@ export class Interface extends AKElement implements AkInterface { this[brandContext] = new BrandContextController(this); this[configContext] = new ConfigContextController(this); this[modalController] = new ModalOrchestrationController(this); - this[versionContext] = new VersionContextController(this); } _activateTheme(theme: UiThemeEnum, ...roots: DocumentOrShadowRoot[]): void { @@ -83,20 +79,30 @@ export class Interface extends AKElement implements AkInterface { } } -export type AkEnterpriseInterface = AkInterface & { +export type AkAuthenticatedInterface = AkInterface & { licenseSummary?: LicenseSummary; + version?: Version; }; const enterpriseContext = Symbol("enterpriseContext"); -export class EnterpriseAwareInterface extends Interface { +export class AuthenticatedInterface extends Interface { [enterpriseContext]!: EnterpriseContextController; + [versionContext]!: VersionContextController; @state() licenseSummary?: LicenseSummary; + @state() + version?: Version; + constructor() { super(); + } + + _initContexts(): void { + super._initContexts(); this[enterpriseContext] = new EnterpriseContextController(this); + this[versionContext] = new VersionContextController(this); } } diff --git a/web/src/elements/Interface/VersionContextController.ts b/web/src/elements/Interface/VersionContextController.ts index 161e8ef11eb9..8e87209f755b 100644 --- a/web/src/elements/Interface/VersionContextController.ts +++ b/web/src/elements/Interface/VersionContextController.ts @@ -9,14 +9,14 @@ import type { ReactiveController } from "lit"; import type { Version } from "@goauthentik/api"; import { AdminApi } from "@goauthentik/api"; -import type { AkInterface } from "./Interface"; +import type { AkAuthenticatedInterface } from "./Interface"; export class VersionContextController implements ReactiveController { - host!: ReactiveElementHost; + host!: ReactiveElementHost; context!: ContextProvider<{ __context__: Version | undefined }>; - constructor(host: ReactiveElementHost) { + constructor(host: ReactiveElementHost) { this.host = host; this.context = new ContextProvider(this.host, { context: authentikVersionContext, diff --git a/web/src/elements/Interface/index.ts b/web/src/elements/Interface/index.ts index df771286eb08..3615d3855e5a 100644 --- a/web/src/elements/Interface/index.ts +++ b/web/src/elements/Interface/index.ts @@ -1,4 +1,4 @@ -import { EnterpriseAwareInterface, Interface } from "./Interface"; +import { AuthenticatedInterface, Interface } from "./Interface"; -export { Interface, EnterpriseAwareInterface }; +export { Interface, AuthenticatedInterface }; export default Interface; diff --git a/web/src/user/UserInterface.ts b/web/src/user/UserInterface.ts index 7ee333774a31..dc8577351edc 100644 --- a/web/src/user/UserInterface.ts +++ b/web/src/user/UserInterface.ts @@ -11,7 +11,7 @@ import { me } from "@goauthentik/common/users"; import { WebsocketClient } from "@goauthentik/common/ws"; import "@goauthentik/components/ak-nav-buttons"; import { AKElement } from "@goauthentik/elements/Base"; -import { EnterpriseAwareInterface } from "@goauthentik/elements/Interface"; +import { AuthenticatedInterface } from "@goauthentik/elements/Interface"; import "@goauthentik/elements/ak-locale-context"; import "@goauthentik/elements/buttons/ActionButton"; import "@goauthentik/elements/enterprise/EnterpriseStatusBanner"; @@ -253,7 +253,7 @@ class UserInterfacePresentation extends AKElement { // // @customElement("ak-interface-user") -export class UserInterface extends EnterpriseAwareInterface { +export class UserInterface extends AuthenticatedInterface { @property({ type: Boolean }) notificationDrawerOpen = getURLParam("notificationDrawerOpen", false);