Configuration Options
Last updated
Last updated
On this page different configuration options are listed you can use with Keycloakify.
This option is for Monorepos. More specifically, monorepo system that works with a single package.json at the root of the project.
You can run every subcommand of the keycloakify
CLI tool from the root of your Keycloakify project using the --project
(or -p
) option. Example with the build
command:
<path>
would be typically something like packages/keycloak-theme
This is the name that will appear in the select input of the Keycloak Admin UI that let's you select the theme.
By default it's package.json["name"]
The theme name is also in kcContext.themeName
Providing an array enables you to implement theme variant. See:
Theme VariantsOnly available in Vite projects, not in Webpack
The postBuild hook is called just before Keycloakify bundles the themes resources into the jar.
This gives you the ability to implement some custom transformation.
Let's say, for example, we have a big material-icons
in our public
directory and those icons are used in the main app but not in the Keycloak theme. We can use the postBuild hook to make sure that those icons are not bundled in the generated jar files.
When this function is invoked the current working directory (process.cwd()) is the root of the directory of the files about to be archived.
You can get an idea of how is structured the files inside the jar by extracting it manually:
Note that the script is executed in a different thread. console.log() won't work. If you want to debug you can write your logs into a file.
If this environnement variable is defined this cache directory will be used instead of the default node_modules/.cache/keycloakify
example:
This option is mainly useful if you need to be able to build your theme offline, in a context with network restriction polices.
The Keycloakify caches the default Keycloak theme resources to avoid having to download them over and over.
Keycloakify shifts page generation from the backend to the client. To achieve this, Keycloakify creates a global kcContext
object, which holds the necessary information for generating HTML pages.
This object contains no sensitive dataโonly the information that the Keycloak team considers essential for rendering the various login pages. Additionally, if you have custom plugins, such as keycloak-email-whitelisting, they may introduce additional values into this object.
If you'd like to prevent some values of the FreeMarker context from being forwarded to the client you can do it with the kcContextExclusionsFtl
option.
Let's say in this example that we would like to exclude:
kcContext.keycloakifyVersion
kcContext.realm.actionTokenGeneratedByUserLifespanMinutes
in the register.ftl page
kcContext.realm.idpVerifyAccountLinkActionTokenLifespanMinutes
in the register.ftl page
This is how you would do it:
You can also provide a path to a .ftl file instead of inlining the ftl code in your vite.config.ts file.
The code that you provide will be injected here.
For more detailed example you can refer to this section of the code that defines the the default exclusions:
If you feel limited by this option you can take ownership of the FreeMarker template that generates the kcContext. Do do this using the wonderfull patch-package.
And edit the FreeMarker template that generates the KcContext in:
node_modules/keycloakify/src/bin/keycloakify/generateFtl/kcContextDeclarationTemplate.ftl
You can then create a diff for your changes by running:
Then add a postinstall script to your package.json:
This option enables you to configure in which directory the .jar files should be created.
By default it's ./dist_keycloak
Configure the groupId
that will appear in the pom.xml
file.
By default it's the package.json homepage field at reverse with .keycloak at the end.
You can overwrite this using an environment variable:
NOTE: For changing the name of the jar file that is generated by Keycloakify see this option instead: keycloakVersionTargets.
Configure the artifactId
that will appear in the pom.xml
file.
By default it's <themeName>-keycloak-theme
See, keycloak.themeName
option.
You can overwrite this using an environment variable:
In this sub folder are listed the few build options that are only relevant in Webpack project.
Be aware, theses are not preferences, they have to reflect your webpack configuration!
In the Create React App setup, when you run yarn build, a build/ directory is generated. If, in your setup it's an other directory you can use this option:a
By default it's build
.
In the Creact React App setup, when you run yarn build, a build/ directory is generated. I this directory there's a static directory/. If, in your setup it's an other directory you can use this option:
By default it's static
.
To enable to test your theme locally, in storybook or with yarn start Keycloakify copies the default theme resources, primarily constituted of PatternFly, the CSS framework used for the default theme.
This option allows you to customize what's the public directory in your case. By default it's public/
but in angular for example it's src/assets/
.
By default it is ~/public
You can also use the PUBLIC_DIR_PATH
environnement variable. Example: