Theming
We have customized both the Keycloak login theme and the email templates to align with our branding and to support the swedish locale.
You can find the customized themes in the Keycloak Admin Console under the “Realm Settings” → “Themes” tab.
To find the source code for the themes, check the keycloak repository.
Update login theme
Section titled “Update login theme”To update layout or styles of the login theme:
- First make sure you can connect to the database used by Keycloak. If you haven’t done so before you need to follow the instructions in the Tools section on the Database page.
- Make changes to the files in the
themes/<theme-name>/loginfolder in the repository. - Push and deploy the updated code.
- This is important: You need to clear the cache in keycloak for the changes to take effect. To give you some background, you can read this article on Medium about How to drop Keycloak theme cache without clearing browser data. So, first you need to inspect which resource tag is being used for the theme resources. You can do this by inspecting the network requests in your browser developer tools when loading the keycloak login page. Look for requests to CSS or JS files from Keycloak and check the query parameter
resourceto find the tag. Once you have identified the resource tag, you’ll need to connect to the database Azure Verksamhet Dev or Azure Verksamhet Prod depending on which environment your updating. Then update the resource tag (theid) in themigration_modeltable. - Lastly, the revision needs to be restarted in Azure container apps for the changes to be visible. Visit the Azure portal, navigate to the Keycloak container app, and restart the revision.
To update messages, i.e. localized strings, in the login theme:
The portal theme extends the base theme and overrides some of the message properties to provide localized text. Some messages are also customized to better fit our use cases.
In themes/base/base/login/messages/messages_sv.properties, you can find the swedish translations for the base theme messages. If you need to update any of these messages, you can do so by modifying this file.
In themes/portal/login/messages/messages_sv.properties, you can find the swedish translations for the portal theme messages. This file also contains overrides for some of the base theme messages. If you need to update any of these messages, you can do so by modifying this file.
When the code has been deployed, the revision needs to be restarted in Azure container apps for the changes to be visible. Visit the Azure portal, navigate to the Keycloak container app, and restart the revision.
Update email templates
Section titled “Update email templates”To update the email templates used by Keycloak:
- Make changes to the files in the
themes/<theme-name>/emailfolder in the repository. - Push and deploy the updated code.
- Lastly, the revision needs to be restarted in Azure container apps for the changes to be visible. Visit the Azure portal, navigate to the Keycloak container app, and restart the revision.