Deploying custom Keycloak theme with Operator (v15.1.1 & v16.0.0)

2.2k views Asked by At

I have a theme with a size >1MB (which precludes the configmap-solution provided as an answer to this question).

This theme has been been packaged according to the Server Development Guide - its folder structure is

META-INF/keycloak-themes.json
themes/[themeName]/login/login.ftl
themes/[themeName]/login/login-reset-password.ftl    
themes/[themeName]/login/template.ftl
themes/[themeName]/login/template.html
themes/[themeName]/login/theme.properties
themes/[themeName]/login/messages/messages_de.properties
themes/[themeName]/login/messages/messages_en.properties
themes/[themeName]/login/resources/[...]

The contents of keycloak-themes.json are

{
    "themes": [{
        "name" : "[themeName]",
        "types": [ "login" ]
    }]
}

where [themeName] is my theme name.

Keycloak is running with 3 instances, its resource spec includes:

extensions:
  - [URL-to-jar]

Deployment was successful according to the logs of each pod - each log contains a message containing

Deployed "[jar-name].jar" (runtime-name : "[jar-name].jar")

However, in the admin console, I cannot select the theme from the extension for the login-theme. Creating a new realm via crd with a preconfigured login-theme via spec-entry

loginTheme: [themeName]

also does not work - in the admin-console, the selected entry for the login-theme is empty.

I may be missing something basic, but it seems like this ought to work according to this answer if I am not mistaken.

1

There are 1 answers

0
MBauerDC On BEST ANSWER

As is so often the case, an uncaught typo was the source of the error.

The directory-structure must not be

  • META-INF/keycloak-themes.json
  • themes/[theme-name]/[theme-role]/theme.properties
  • [...]

But instead

  • META-INF/keycloak-themes.json
  • theme/[theme-name]/[theme-role]/theme.properties
  • [...]

Given a correct structure, keycloak-operator can successfully deploy and load custom-themes as jar-extensions.