Skip to content

Commit bef6eed

Browse files
feat: make demo-mode login banner overridable via DEMO_BANNER_HTML
Add DEMO_BANNER_HTML env var that replaces the built-in demo banner with custom HTML when set. Empty (default) keeps the existing banner. Documented in .env.example and deployment.md. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1a3cc4d commit bef6eed

5 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎.env.example‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ SEED_ON_BOOT=true
3838
DEMO_MODE=false
3939
DEMO_USERNAME=admin
4040
DEMO_PASSWORD=change-me
41+
# Optional: override the demo-mode login banner with custom HTML.
42+
# When empty, the built-in banner is shown. Trusted operator content only.
43+
#DEMO_BANNER_HTML=<div class="mb-4 …">Your custom banner</div>
4144

4245
# --- PostgreSQL ---------------------------------------------------------------
4346
# In Docker Compose the web/worker containers reach Postgres at host `postgres`

‎config/settings.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ def _csrf_trusted_origins() -> list[str]:
323323
DEMO_MODE = env_bool("DEMO_MODE", False)
324324
DEMO_USERNAME = os.environ.get("DEMO_USERNAME", "studio")
325325
DEMO_PASSWORD = os.environ.get("DEMO_PASSWORD", "localdevpass123")
326+
# Optional: override the demo-mode login banner with custom HTML (trusted
327+
# operator content only). When empty, the built-in banner is shown.
328+
DEMO_BANNER_HTML = os.environ.get("DEMO_BANNER_HTML", "")
326329

327330
# Framing policy:
328331
# - Demo mode (HF Spaces / public demos): allow cross-origin framing so the

‎docs/deployment.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ override them when you deliberately need to.
186186
| `WORKER_POOL` | Worker label (`cpu` by default). |
187187
| `BOOTSTRAP_USERNAME`, `BOOTSTRAP_EMAIL`, `BOOTSTRAP_PASSWORD`, `BOOTSTRAP_PROJECT_NAME` | First admin user and workspace. |
188188
| `DEMO_MODE`, `DEMO_USERNAME`, `DEMO_PASSWORD` | Prefilled demo login and the HF iframe cookie/CSRF policy. |
189+
| `DEMO_BANNER_HTML` | Optional custom HTML for the demo-mode login banner. Empty = built-in banner. Trusted operator content only. |
189190
| `WORKOS_CLIENT_ID`, `WORKOS_API_KEY` | Optional passwordless email sign-in. |
190191
| `SIMPLEAUDIT_GRAVATAR` | `true` = show Gravatar avatars (the browser sends the MD5 hash of the user's email to gravatar.com). Default off: the user's initial is shown. |
191192
| `SENTRY_DSN`, `SENTRY_ENVIRONMENT` | Optional error tracking. |

‎infra/ui.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ def get_context_data(self, **kw):
336336
kw["demo_mode"] = True
337337
kw["demo_username"] = settings.DEMO_USERNAME
338338
kw["demo_password"] = settings.DEMO_PASSWORD
339+
kw["demo_banner_html"] = getattr(settings, "DEMO_BANNER_HTML", "")
339340
kw["workos_enabled"] = getattr(settings, "WORKOS_ENABLED", False)
340341
kw["registration_enabled"] = registration_enabled()
341342
# The login page is what unauthenticated visitors land on when they

‎templates/auth/login.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
<!-- Demo mode banner -->
3232
{% if demo_mode %}
33+
{% if demo_banner_html %}
34+
{{ demo_banner_html|safe }}
35+
{% else %}
3336
<div class="mb-4 flex items-start gap-3 rounded-xl border border-accent/30 bg-accent/10 px-4 py-3">
3437
<svg class="mt-0.5 w-5 h-5 shrink-0 text-accent" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
3538
<div class="text-sm text-gray-300">
@@ -44,6 +47,7 @@
4447
</div>
4548
</div>
4649
{% endif %}
50+
{% endif %}
4751

4852
<!-- Secondary: username/password (always available) -->
4953
<form method="post" class="bg-surface-raised rounded-2xl border border-gray-800 p-8 space-y-5 shadow-xl">

0 commit comments

Comments
 (0)