Creating custom theme in keycloak-x

Hello!

I found out about keycloak-x and am very exited about the possibilities. Everything is working fine, but I can’t for the life of me figure out how to create a custom theme.

I read something about creating a theme jar and putting it in the providers directory, but I am unsure how to do that.

Have anyone else experimented with this?

Hi @jntn ,
Did you tried to build server with;
mvn -Pdistribution -pl distribution/server-x-dist/ -am -Dmaven.test.skip clean install

After the successfully build you can find the distribution in; {Keycloak}/distribution/server-x-dist/target

Greetings,
Yigit

try this Themes | keycloak-documentation
once the zip is created extract it to the themes folder in the keycloak

Oh wow, @firefox 's linked gitbook docs do indeed say

create a ZIP archive with the theme resources

This could have save me loads of time… But I only found the official docs which say

create a JAR archive with the theme resources

So I dug up keycloakify and copied their process of creating a jar.

It boils down to:

  • Having a theme folder and META-INF/keycloak-themes.json in the current folder, according to the docs
  • creating ./src/main/resources/ and moving the theme and META-INF folder in there
  • creating a pom.xml in ./ like:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.example.theme</groupId>
	<artifactId>foo</artifactId>
	<version>0.0.1</version>
	<name>foo</name>
	<description />
</project>
  • running mvn package in ./

The jar will end up in ./target, eg. ./target/foo-0.0.1.jar :tada:

While I only deployed the JAR to a normal keycloak instance (by copying it to /opt/jboss/keycloak/standalone/deployments)
the blog post introducing keycloak-x says:

The providers directory is where you should deploy your JAR files with your custom providers or themes jar.

I hope this helps anyone, and fully expect myself to stumble across this exact post next time i have to touch keycloak themes :sweat_smile:

1 Like

Anyone successful in creating custom themes in Keycloak-X? I tried all the things but still no luck.

  1. As per the documentation (though it is for Keycloak not Keycloak-X), we can just copy the mytheme content in themes folder and this WORKS. Tested the same in Traditional Keycloak.
  2. As mentioned by @iudex, created the jar file and put it in providers folder. Restarted ketcloak-x, but no luck.

I am doing the same like tekgainers. We copy our themes only in the themes folder and it works. I never understood why someone is doing the extra effort to create a jar and copy it anywhere. It is faster and easier to copy only the themes into the theme folder instead of creating every time a jar file.

For those who are using/ playing around with Keycloak.X. Custom themes is working with jar file. I was missing the below step and hope someone will find it useful:
Step 1: Put the jar in the provider folder.
Step 2: Run the following command “kc.bat config” for windows and “kc.sh config” for linux
Step 3: Start Keycloak.X

@Paul6552 - Are you using Keycloak.X? Copying themes folder works perfectly in Keycloak and not in Keycloak.X. Let me know if only themes folder copying works for you in Keycloak.X.

2 Likes

Sry I only saw “Creating custom theme in keycloak” missed the X.

Why isnt it working anymore in keycloak X to copy themes folder? Why do we have to make a jar file? Isnt it easier only to copy the files in the theme folder and finished?

@tekgainers Thanks brother, that thing also worked for me.

Step 1: Put the jar in the provider folder.
Step 2: Run the following command “kc.bat config” for windows and “kc.sh config” for linux
Step 3: Start Keycloak.X