diff --git a/.env b/.env index fcc4983c3..cd9a02ab1 100644 --- a/.env +++ b/.env @@ -188,6 +188,10 @@ ADMIN_TOUCH_BUTTON_REGIONS=false ADMIN_LOGIN_METHODS='[{"type":"username-password","enabled":true,"provider":"username-password","label":""}]' # Enable enhanced preview mode with additional features. ADMIN_ENHANCED_PREVIEW=false +# Optional HTML block shown in the login sidebar. +# Allowed tags: strong, em, b, i, br, p, a, span. Allowed attrs: href, title, target, rel, class. +# Leave empty to hide the sidebar text card entirely. +ADMIN_LOGIN_SCREEN_TEXT= ###< Admin configuration ### ###> Client configuration ### diff --git a/CHANGELOG.md b/CHANGELOG.md index 105ad9c08..01516b867 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- Made the Admin login sidebar text configurable via the new `ADMIN_LOGIN_SCREEN_TEXT` + env var. The value accepts a small allow-list of HTML tags (sanitized client-side + with DOMPurify); when empty the sidebar card is hidden entirely. Removed the + bundled Danish "medarbejder/borger MitID" copy that previously rendered by default. +- Fixed login screen styling issue resulting in header not filling parent in some breakpoints. - Fixed Calendar and Colibo feed configuration urls and added [] result when no locationEndpoint is set. - Fixed baked-in `.env` shipping `APP_ENV=dev` in the API image; rewritten to `prod` at build time so direct reads don't try to bootstrap a dev environment the prod-only dependencies can't satisfy. diff --git a/README.md b/README.md index 9171e7fb7..6255876e8 100644 --- a/README.md +++ b/README.md @@ -480,6 +480,7 @@ ADMIN_SHOW_SCREEN_STATUS=false ADMIN_TOUCH_BUTTON_REGIONS=false ADMIN_LOGIN_METHODS='[{"type":"username-password","enabled":true,"provider":"username-password","label":""}]' ADMIN_ENHANCED_PREVIEW=false +ADMIN_LOGIN_SCREEN_TEXT='' ###< Admin configuration ### ``` @@ -529,6 +530,16 @@ ADMIN_ENHANCED_PREVIEW=false See [Preview mode in the Client](#preview-mode-in-the-client). **Default**: Disabled. +- ADMIN_LOGIN_SCREEN_TEXT: Optional explanatory text rendered in the sidebar card on the Admin login page. + Accepts a small allow-list of HTML tags (`strong`, `em`, `b`, `i`, `br`, `p`, `a`, `span`) and attributes + (`href`, `title`, `target`, `rel`, `class`); the value is sanitized client-side with DOMPurify before being + rendered. Leave empty to hide the sidebar card entirely. + + ```dotenv + ADMIN_LOGIN_SCREEN_TEXT='
Er du medarbejder skal du benytte medarbejderlogin.
Er du borger skal du benytte MitID login.
' + ``` + + **Default**: Empty (no sidebar card shown). ### Client configuration diff --git a/assets/admin/components/navigation/login-sidebar/login-sidebar.jsx b/assets/admin/components/navigation/login-sidebar/login-sidebar.jsx index 07600ce85..a67ced707 100644 --- a/assets/admin/components/navigation/login-sidebar/login-sidebar.jsx +++ b/assets/admin/components/navigation/login-sidebar/login-sidebar.jsx @@ -1,22 +1,37 @@ -import { useTranslation, Trans } from "react-i18next"; +import { useEffect, useState } from "react"; +import DOMPurify from "dompurify"; +import AdminConfigLoader from "../../util/admin-config-loader"; import Logo from "../logo"; +const SANITIZE_OPTIONS = { + ALLOWED_TAGS: ["strong", "em", "b", "i", "br", "p", "a", "span"], + ALLOWED_ATTR: ["href", "title", "target", "rel", "class"], +}; + const LoginSidebar = () => { - const { t } = useTranslation("common", { keyPrefix: "login-sidebar" }); + const [customHtml, setCustomHtml] = useState(""); + + useEffect(() => { + AdminConfigLoader.loadConfig().then((cfg) => { + const raw = cfg?.loginScreenText?.trim(); + if (raw) setCustomHtml(DOMPurify.sanitize(raw, SANITIZE_OPTIONS)); + }); + }, []); return (
-
-