Open source 2025

Keycloak Bootstrap Theme

A login and e-mail theme for Keycloak based on Bootstrap: light and dark without flicker, passkeys with AutoFill, four languages and a strict Content Security Policy without unsafe-inline.

Since

2025

Licence

MIT / Apache-2.0

Login light
4
languages: DE, EN, FR, ES
2
themes: light and dark
0
unsafe-inline in the CSP
100 KB
CSS limit, checked in CI

Technologies

Keycloak FreeMarker Bootstrap WebAuthn / Passkeys Content Security Policy Docker GitLab CI PurgeCSS csso terser

The Challenge

Keycloak's default theme looks technical and rarely matches your own brand. Custom themes often copy inline scripts along, which rules out a strict Content Security Policy, and newer features such as passkeys are missing.

The Solution

A complete login and e-mail theme based on Bootstrap's sign-in example, in plain FreeMarker and CSS. It supports passkeys with a sign-in button, AutoFill and registration, plus OTP, registration and password reset, and works without inline scripts.

What the theme offers

Passkeys

Sign-in button, conditional display in the browser's AutoFill and registration of new passkeys; the WebAuthn modules are taken from Keycloak itself at build time.

Light and dark

Both themes without a flash of the wrong colours, with contrast to WCAG AA according to the README.

Configurable

Logo, favicon, copyright year, signature per realm and a cache buster via theme.properties; languages German, English, French and Spanish.

Strict Content Security Policy

The theme needs no inline scripts or inline styles and runs under script-src 'self' and style-src 'self'. A small Python tool reads the hashes Keycloak itself still embeds from a running instance and prints a matching CSP. Messages are output through kcSanitize.

Build

A multi-stage Dockerfile takes the WebAuthn modules from the Keycloak image, shrinks CSS and JavaScript with PurgeCSS, csso and terser, and delivers either a complete Keycloak image or just the theme folder. GitLab CI checks the build, the artefacts and that the CSS stays under 100 KB.

Use and licence

No React, no Node at runtime and no CDN: the theme consists of FreeMarker templates, CSS and a little JavaScript. Its own code is under the MIT licence, templates derived from Keycloak additionally under Apache-2.0.

Privacy

All fonts, styles and scripts come from your own Keycloak server; the theme makes no requests to third parties.

Results

A modern Keycloak theme that supports passkeys, fits your own brand and can run under a strict Content Security Policy.

Gallery

Images from the project's GitHub repository.