diff --git a/web/src/admin/applications/wizard/methods/ldap/ak-application-wizard-authentication-by-ldap.ts b/web/src/admin/applications/wizard/methods/ldap/ak-application-wizard-authentication-by-ldap.ts index 8858f5bf4..73f78135b 100644 --- a/web/src/admin/applications/wizard/methods/ldap/ak-application-wizard-authentication-by-ldap.ts +++ b/web/src/admin/applications/wizard/methods/ldap/ak-application-wizard-authentication-by-ldap.ts @@ -6,7 +6,7 @@ import "@goauthentik/components/ak-number-input"; import "@goauthentik/components/ak-radio-input"; import "@goauthentik/components/ak-switch-input"; import "@goauthentik/components/ak-text-input"; -import { WithTenantConfig } from "@goauthentik/elements/Interface/tenantProvider"; +import { WithBrandConfig } from "@goauthentik/elements/Interface/brandProvider"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; @@ -31,7 +31,7 @@ import { } from "./LDAPOptionsAndHelp"; @customElement("ak-application-wizard-authentication-by-ldap") -export class ApplicationWizardApplicationDetails extends WithTenantConfig(BaseProviderPanel, true) { +export class ApplicationWizardApplicationDetails extends WithBrandConfig(BaseProviderPanel) { render() { const provider = this.wizard.provider as LDAPProvider | undefined; @@ -52,7 +52,7 @@ export class ApplicationWizardApplicationDetails extends WithTenantConfig(BasePr

${msg("Flow used for users to authenticate.")}

diff --git a/web/src/admin/applications/wizard/methods/radius/ak-application-wizard-authentication-by-radius.ts b/web/src/admin/applications/wizard/methods/radius/ak-application-wizard-authentication-by-radius.ts index ab4260df0..991676124 100644 --- a/web/src/admin/applications/wizard/methods/radius/ak-application-wizard-authentication-by-radius.ts +++ b/web/src/admin/applications/wizard/methods/radius/ak-application-wizard-authentication-by-radius.ts @@ -2,7 +2,7 @@ import "@goauthentik/admin/common/ak-crypto-certificate-search"; import "@goauthentik/admin/common/ak-flow-search/ak-tenanted-flow-search"; import { ascii_letters, digits, first, randomString } from "@goauthentik/common/utils"; import "@goauthentik/components/ak-text-input"; -import { WithTenantConfig } from "@goauthentik/elements/Interface/tenantProvider"; +import { WithBrandConfig } from "@goauthentik/elements/Interface/brandProvider"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; @@ -16,10 +16,7 @@ import { FlowsInstancesListDesignationEnum, RadiusProvider } from "@goauthentik/ import BaseProviderPanel from "../BaseProviderPanel"; @customElement("ak-application-wizard-authentication-by-radius") -export class ApplicationWizardAuthenticationByRadius extends WithTenantConfig( - BaseProviderPanel, - true, -) { +export class ApplicationWizardAuthenticationByRadius extends WithBrandConfig(BaseProviderPanel) { render() { const provider = this.wizard.provider as RadiusProvider | undefined; @@ -40,7 +37,7 @@ export class ApplicationWizardAuthenticationByRadius extends WithTenantConfig(

${msg("Flow used for users to authenticate.")}

diff --git a/web/src/admin/groups/RelatedUserList.ts b/web/src/admin/groups/RelatedUserList.ts index 5a1f0ebd8..04099f994 100644 --- a/web/src/admin/groups/RelatedUserList.ts +++ b/web/src/admin/groups/RelatedUserList.ts @@ -9,11 +9,11 @@ import { MessageLevel } from "@goauthentik/common/messages"; import { uiConfig } from "@goauthentik/common/ui/config"; import { first } from "@goauthentik/common/utils"; import "@goauthentik/components/ak-status-label"; +import { WithBrandConfig } from "@goauthentik/elements/Interface/brandProvider"; import { CapabilitiesEnum, WithCapabilitiesConfig, } from "@goauthentik/elements/Interface/capabilitiesProvider"; -import { WithTenantConfig } from "@goauthentik/elements/Interface/tenantProvider"; import "@goauthentik/elements/buttons/ActionButton"; import "@goauthentik/elements/buttons/Dropdown"; import "@goauthentik/elements/forms/DeleteBulkForm"; @@ -110,9 +110,8 @@ export class RelatedUserAdd extends Form<{ users: number[] }> { } @customElement("ak-user-related-list") -export class RelatedUserList extends WithTenantConfig( +export class RelatedUserList extends WithBrandConfig( WithCapabilitiesConfig(Table, true), - true, ) { expandable = true; checkbox = true; @@ -298,7 +297,7 @@ export class RelatedUserList extends WithTenantConfig( ${msg("Set password")} - ${this.tenant?.flowRecovery + ${this.brand?.flowRecovery ? html` , true) { +export class LDAPProviderFormPage extends WithBrandConfig(ModelForm, true) { async loadInstance(pk: number): Promise { return new ProvidersApi(DEFAULT_CONFIG).providersLdapRetrieve({ id: pk, @@ -76,7 +76,7 @@ export class LDAPProviderFormPage extends WithTenantConfig(ModelForm

${msg("Flow used for users to authenticate.")}

diff --git a/web/src/admin/providers/radius/RadiusProviderForm.ts b/web/src/admin/providers/radius/RadiusProviderForm.ts index fda74ef46..c117e463c 100644 --- a/web/src/admin/providers/radius/RadiusProviderForm.ts +++ b/web/src/admin/providers/radius/RadiusProviderForm.ts @@ -1,6 +1,6 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { ascii_letters, digits, first, randomString } from "@goauthentik/common/utils"; -import { WithTenantConfig } from "@goauthentik/elements/Interface/tenantProvider"; +import { WithBrandConfig } from "@goauthentik/elements/Interface/brandProvider"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; @@ -14,7 +14,7 @@ import { customElement } from "lit/decorators.js"; import { FlowsInstancesListDesignationEnum, ProvidersApi, RadiusProvider } from "@goauthentik/api"; @customElement("ak-provider-radius-form") -export class RadiusProviderFormPage extends WithTenantConfig( +export class RadiusProviderFormPage extends WithBrandConfig( ModelForm, true, ) { @@ -68,7 +68,7 @@ export class RadiusProviderFormPage extends WithTenantConfig(

${msg("Flow used for users to authenticate.")}

diff --git a/web/src/admin/users/UserListPage.ts b/web/src/admin/users/UserListPage.ts index e90228722..9b10b2648 100644 --- a/web/src/admin/users/UserListPage.ts +++ b/web/src/admin/users/UserListPage.ts @@ -12,11 +12,11 @@ import { DefaultUIConfig, uiConfig } from "@goauthentik/common/ui/config"; import { first } from "@goauthentik/common/utils"; import "@goauthentik/components/ak-status-label"; import { rootInterface } from "@goauthentik/elements/Base"; +import { WithBrandConfig } from "@goauthentik/elements/Interface/brandProvider"; import { CapabilitiesEnum, WithCapabilitiesConfig, } from "@goauthentik/elements/Interface/capabilitiesProvider"; -import { WithTenantConfig } from "@goauthentik/elements/Interface/tenantProvider"; import { PFSize } from "@goauthentik/elements/Spinner"; import "@goauthentik/elements/TreeView"; import "@goauthentik/elements/buttons/ActionButton"; @@ -91,10 +91,8 @@ const recoveryButtonStyles = css` `; @customElement("ak-user-list") -export class UserListPage extends WithTenantConfig( - WithCapabilitiesConfig(TablePage, true), - true, -) { +export class UserListPage extends WithBrandConfig( + WithCapabilitiesConfig(TablePage, true)) { expandable = true; checkbox = true; @@ -355,7 +353,7 @@ export class UserListPage extends WithTenantConfig( ${msg("Set password")} - ${this.tenant.flowRecovery + ${this.brand.flowRecovery ? html` | undefined = Promise.resolve(globalAK().config); export function config(): Promise { @@ -16,7 +22,7 @@ export function config(): Promise { return globalConfigPromise; } -export function tenantSetFavicon(tenant: CurrentTenant) { +export function brandSetFavicon(brand: CurrentBrand) { /** * * @@ -29,36 +35,36 @@ export function tenantSetFavicon(tenant: CurrentTenant) { relIcon.rel = rel; document.getElementsByTagName("head")[0].appendChild(relIcon); } - relIcon.href = tenant.brandingFavicon; + relIcon.href = brand.brandingFavicon; }); } -export function tenantSetLocale(tenant: CurrentTenant) { - if (tenant.defaultLocale === "") { +export function brandSetLocale(brand: CurrentBrand) { + if (brand.defaultLocale === "") { return; } - console.debug("authentik/locale: setting locale from tenant default"); + console.debug("authentik/locale: setting locale from brand default"); window.dispatchEvent( new CustomEvent(EVENT_LOCALE_REQUEST, { composed: true, bubbles: true, - detail: { locale: tenant.defaultLocale }, + detail: { locale: brand.defaultLocale }, }), ); } -let globalTenantPromise: Promise | undefined = Promise.resolve(globalAK().tenant); -export function tenant(): Promise { - if (!globalTenantPromise) { - globalTenantPromise = new CoreApi(DEFAULT_CONFIG) +let globalBrandPromise: Promise | undefined = Promise.resolve(globalAK().tenant); +export function brand(): Promise { + if (!globalBrandPromise) { + globalBrandPromise = new CoreApi(DEFAULT_CONFIG) .coreTenantsCurrentRetrieve() - .then((tenant) => { - tenantSetFavicon(tenant); - tenantSetLocale(tenant); - return tenant; + .then((brand) => { + brandSetFavicon(brand); + brandSetLocale(brand); + return brand; }); } - return globalTenantPromise; + return globalBrandPromise; } export function getMetaContent(key: string): string { @@ -90,9 +96,9 @@ window.addEventListener(EVENT_REFRESH, () => { // Upon global refresh, disregard whatever was pre-hydrated and // actually load info from API globalConfigPromise = undefined; - globalTenantPromise = undefined; + globalBrandPromise = undefined; config(); - tenant(); + brand(); }); console.debug(`authentik(early): version ${VERSION}, apiBase ${DEFAULT_CONFIG.basePath}`); diff --git a/web/src/common/api/middleware.ts b/web/src/common/api/middleware.ts index 745a5d1c9..b03fd479a 100644 --- a/web/src/common/api/middleware.ts +++ b/web/src/common/api/middleware.ts @@ -18,13 +18,13 @@ export interface RequestInfo { } export class LoggingMiddleware implements Middleware { - tenant: CurrentTenant; - constructor(tenant: CurrentTenant) { - this.tenant = tenant; + brand: CurrentTenant; + constructor(brand: CurrentTenant) { + this.brand = brand; } post(context: ResponseContext): Promise { - let msg = `authentik/api[${this.tenant.matchedDomain}]: `; + let msg = `authentik/api[${this.brand.matchedDomain}]: `; // https://developer.mozilla.org/en-US/docs/Web/API/console#styling_console_output msg += `%c${context.response.status}%c ${context.init.method} ${context.url}`; let style = ""; diff --git a/web/src/elements/AuthentikContexts.ts b/web/src/elements/AuthentikContexts.ts index 02fa89316..4d97ce633 100644 --- a/web/src/elements/AuthentikContexts.ts +++ b/web/src/elements/AuthentikContexts.ts @@ -1,11 +1,9 @@ import { createContext } from "@lit-labs/context"; -import type { Config, CurrentTenant } from "@goauthentik/api"; +import type { Config, CurrentTenant as CurrentBrand } from "@goauthentik/api"; export const authentikConfigContext = createContext(Symbol("authentik-config-context")); -export const authentikTenantContext = createContext( - Symbol("authentik-tenant-context"), -); +export const authentikBrandContext = createContext(Symbol("authentik-brand-context")); export default authentikConfigContext; diff --git a/web/src/elements/Interface/Interface.ts b/web/src/elements/Interface/Interface.ts index b2470cfd2..a3ca2bb3a 100644 --- a/web/src/elements/Interface/Interface.ts +++ b/web/src/elements/Interface/Interface.ts @@ -1,8 +1,8 @@ -import { config, tenant } from "@goauthentik/common/api/config"; +import { brand, config } from "@goauthentik/common/api/config"; import { UIConfig, uiConfig } from "@goauthentik/common/ui/config"; import { + authentikBrandContext, authentikConfigContext, - authentikTenantContext, } from "@goauthentik/elements/AuthentikContexts"; import type { AdoptedStyleSheetsElement } from "@goauthentik/elements/types"; import { ensureCSSStyleSheet } from "@goauthentik/elements/utils/ensureCSSStyleSheet"; @@ -12,13 +12,13 @@ import { state } from "lit/decorators.js"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; -import { Config, CurrentTenant, UiThemeEnum } from "@goauthentik/api"; +import { Config, CurrentTenant as CurrentBrand, UiThemeEnum } from "@goauthentik/api"; import { AKElement } from "../Base"; type AkInterface = HTMLElement & { getTheme: () => Promise; - tenant?: CurrentTenant; + brand?: CurrentBrand; uiConfig?: UIConfig; config?: Config; }; @@ -45,28 +45,28 @@ export class Interface extends AKElement implements AkInterface { return this._config; } - _tenantContext = new ContextProvider(this, { - context: authentikTenantContext, + _brandContext = new ContextProvider(this, { + context: authentikBrandContext, initialValue: undefined, }); - _tenant?: CurrentTenant; + _brand?: CurrentBrand; @state() - set tenant(c: CurrentTenant) { - this._tenant = c; - this._tenantContext.setValue(c); + set brand(c: CurrentBrand) { + this._brand = c; + this._brandContext.setValue(c); this.requestUpdate(); } - get tenant(): CurrentTenant | undefined { - return this._tenant; + get brand(): CurrentBrand | undefined { + return this._brand; } constructor() { super(); document.adoptedStyleSheets = [...document.adoptedStyleSheets, ensureCSSStyleSheet(PFBase)]; - tenant().then((tenant) => (this.tenant = tenant)); + brand().then((brand) => (this.brand = brand)); config().then((config) => (this.config = config)); this.dataset.akInterfaceRoot = "true"; } diff --git a/web/src/elements/Interface/brandProvider.ts b/web/src/elements/Interface/brandProvider.ts new file mode 100644 index 000000000..28c64daca --- /dev/null +++ b/web/src/elements/Interface/brandProvider.ts @@ -0,0 +1,20 @@ +import { authentikBrandContext } from "@goauthentik/elements/AuthentikContexts"; + +import { consume } from "@lit-labs/context"; +import type { LitElement } from "lit"; + +import type { CurrentTenant as CurrentBrand } from "@goauthentik/api"; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type Constructor = abstract new (...args: any[]) => T; + +export function WithBrandConfig>( + superclass: T, + subscribe = true, +) { + abstract class WithBrandProvider extends superclass { + @consume({ context: authentikBrandContext, subscribe }) + public brand!: CurrentBrand; + } + return WithBrandProvider; +} diff --git a/web/src/elements/Interface/tenantProvider.ts b/web/src/elements/Interface/tenantProvider.ts deleted file mode 100644 index e1837935c..000000000 --- a/web/src/elements/Interface/tenantProvider.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { authentikTenantContext } from "@goauthentik/elements/AuthentikContexts"; - -import { consume } from "@lit-labs/context"; -import type { LitElement } from "lit"; - -import type { CurrentTenant } from "@goauthentik/api"; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type Constructor = abstract new (...args: any[]) => T; - -export function WithTenantConfig>( - superclass: T, - subscribe = false, -) { - abstract class WithTenantProvider extends superclass { - @consume({ context: authentikTenantContext, subscribe }) - public tenant!: CurrentTenant; - } - return WithTenantProvider; -} diff --git a/web/src/elements/PageHeader.ts b/web/src/elements/PageHeader.ts index ed8219ef9..04b7c2afc 100644 --- a/web/src/elements/PageHeader.ts +++ b/web/src/elements/PageHeader.ts @@ -9,7 +9,7 @@ import { import { currentInterface } from "@goauthentik/common/sentry"; import { me } from "@goauthentik/common/users"; import { AKElement } from "@goauthentik/elements/Base"; -import { WithTenantConfig } from "@goauthentik/elements/Interface/tenantProvider"; +import { WithBrandConfig } from "@goauthentik/elements/Interface/brandProvider"; import "@patternfly/elements/pf-tooltip/pf-tooltip.js"; import { msg } from "@lit/localize"; @@ -24,7 +24,7 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css"; import { EventsApi } from "@goauthentik/api"; @customElement("ak-page-header") -export class PageHeader extends WithTenantConfig(AKElement, true) { +export class PageHeader extends WithBrandConfig(AKElement) { @property() icon?: string; @@ -37,7 +37,7 @@ export class PageHeader extends WithTenantConfig(AKElement, true) { @property() set header(value: string) { const currentIf = currentInterface(); - let title = this.tenant?.brandingTitle || TITLE_DEFAULT; + let title = this.brand?.brandingTitle || TITLE_DEFAULT; if (currentIf === "admin") { title = `${msg("Admin")} - ${title}`; } diff --git a/web/src/elements/sidebar/SidebarBrand.ts b/web/src/elements/sidebar/SidebarBrand.ts index b603c3c75..459021759 100644 --- a/web/src/elements/sidebar/SidebarBrand.ts +++ b/web/src/elements/sidebar/SidebarBrand.ts @@ -1,6 +1,6 @@ import { EVENT_SIDEBAR_TOGGLE } from "@goauthentik/common/constants"; import { AKElement } from "@goauthentik/elements/Base"; -import { WithTenantConfig } from "@goauthentik/elements/Interface/tenantProvider"; +import { WithBrandConfig } from "@goauthentik/elements/Interface/brandProvider"; import { CSSResult, TemplateResult, css, html } from "lit"; import { customElement } from "lit/decorators.js"; @@ -27,7 +27,7 @@ export const DefaultTenant: CurrentTenant = { }; @customElement("ak-sidebar-brand") -export class SidebarBrand extends WithTenantConfig(AKElement, true) { +export class SidebarBrand extends WithBrandConfig(AKElement) { static get styles(): CSSResult[] { return [ PFBase, @@ -85,7 +85,7 @@ export class SidebarBrand extends WithTenantConfig(AKElement, true) {
authentik Logo diff --git a/web/src/flow/FlowExecutor.ts b/web/src/flow/FlowExecutor.ts index 0322a0c47..814a99461 100644 --- a/web/src/flow/FlowExecutor.ts +++ b/web/src/flow/FlowExecutor.ts @@ -54,9 +54,9 @@ export class FlowExecutor extends Interface implements StageHost { set challenge(value: ChallengeTypes | undefined) { this._challenge = value; if (value?.flowInfo?.title) { - document.title = `${value.flowInfo?.title} - ${this.tenant?.brandingTitle}`; + document.title = `${value.flowInfo?.title} - ${this.brand?.brandingTitle}`; } else { - document.title = this.tenant?.brandingTitle || TITLE_DEFAULT; + document.title = this.brand?.brandingTitle || TITLE_DEFAULT; } this.requestUpdate(); } @@ -500,7 +500,7 @@ export class FlowExecutor extends Interface implements StageHost {