import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { first } from "@goauthentik/common/utils"; import "@goauthentik/components/ak-number-input"; import "@goauthentik/components/ak-switch-input"; import "@goauthentik/components/ak-text-input"; import "@goauthentik/elements/ak-array-input.js"; import { Form } from "@goauthentik/elements/forms/Form"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/Radio"; import "@goauthentik/elements/forms/SearchSelect"; import "@goauthentik/elements/utils/TimeDeltaHelp"; import { msg } from "@lit/localize"; import { CSSResult, TemplateResult, css, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import PFList from "@patternfly/patternfly/components/List/list.css"; import { AdminApi, FooterLink, Settings, SettingsRequest } from "@goauthentik/api"; import "./AdminSettingsFooterLinks.js"; import { IFooterLinkInput, akFooterLinkInput } from "./AdminSettingsFooterLinks.js"; const DEFAULT_REPUTATION_LOWER_LIMIT = -5; const DEFAULT_REPUTATION_UPPER_LIMIT = 5; @customElement("ak-admin-settings-form") export class AdminSettingsForm extends Form { // // Custom property accessors in Lit 2 require a manual call to requestUpdate(). See: // https://lit.dev/docs/v2/components/properties/#accessors-custom // set settings(value: Settings | undefined) { this._settings = value; this.requestUpdate(); } @property({ type: Object }) get settings() { return this._settings; } private _settings?: Settings; static get styles(): CSSResult[] { return super.styles.concat( PFList, css` ak-array-input { width: 100%; } `, ); } getSuccessMessage(): string { return msg("Successfully updated settings."); } async send(data: SettingsRequest): Promise { const result = await new AdminApi(DEFAULT_CONFIG).adminSettingsUpdate({ settingsRequest: data, }); this.dispatchEvent(new CustomEvent("ak-admin-setting-changed")); return result; } renderForm(): TemplateResult { return html` ${msg( "Configure how authentik should show avatars for users. The following values can be set:", )}

  • none: ${msg( "Disables per-user avatars and just shows a 1x1 pixel transparent picture", )}
  • gravatar: ${msg("Uses gravatar with the user's email address")}
  • initials: ${msg("Generated avatars based on the user's name")}
  • ${msg( "Any URL: If you want to use images hosted on another server, you can set any URL. Additionally, these placeholders can be used:", )}
    • %(username)s: ${msg("The user's username")}
    • %(mail_hash)s: ${msg("The email address, md5 hashed")}
    • %(upn)s: ${msg("The user's UPN, if set (otherwise an empty string)")}
  • ${msg( html`An attribute path like attributes.something.avatar, which can be used in combination with the file field to allow users to upload custom avatars for themselves.`, )}

${msg( "Multiple values can be set, comma-separated, and authentik will fallback to the next mode when no avatar could be found.", )} ${msg( html`For example, setting this to gravatar,initials will attempt to get an avatar from Gravatar, and if the user has not configured on there, it will fallback to a generated avatar.`, )}

`} required >
${msg("Duration after which events will be deleted from the database.")}

${msg( html`When using an external logging solution for archiving, this can be set to minutes=5.`, )}

${msg( "This setting only affects new Events, as the expiration is saved per-event.", )}

`} >
({ name: "", href: "" })} .row=${(f?: FooterLink) => akFooterLinkInput({ ".footerLink": f, "style": "width: 100%", "name": "footer-link", } as unknown as IFooterLinkInput)} >

${msg( "This option configures the footer links on the flow executor pages. The URL is limited to web and mail addresses. If the name is left blank, the URL will be shown.", )}

${msg("Default duration for generated tokens")}

`} >
`; } } declare global { interface HTMLElementTagNameMap { "ak-admin-settings-form": AdminSettingsForm; } }