0

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.

MBauerDC
  • 160
  • 8
  • Hi, Non java dev here, How to create the .jar file(s) from that folder? – Sanjay Prajapati Dec 08 '22 at 09:46
  • 1
    @SanjayPrajapati - you should use the bash `jar` command - see [here](https://docs.oracle.com/javase/7/docs/technotes/tools/solaris/jar.html). I personally call `jar cfM [TARGET-PATH}.jar [SOURCE-DIRECTORY-PATH]` – MBauerDC Dec 09 '22 at 10:35
  • Thank you and then need to put that .jar file into the providers/ directory? I am using Keycloak 20.0.1, I am confused, then what is the use of creating an archive or zip file? – Sanjay Prajapati Dec 09 '22 at 12:07

1 Answers1

3

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.

MBauerDC
  • 160
  • 8