I have a problem with Keycloak (I am a newbie):
We have Keycloak set up and running, defined a custom theme which is used. When a specific event in the application happens I want the User to be logged out and be redirected to a custom static page in Keycloak which contains an error message.
I tried to create a custom.ftl-file in Keycloak file-structure under opt/keycloak/themes/customTheme/login. Then I tried to logout (logout-method has a redirect parameter) the user and redirect him to this custom.ftl file with its path.
Is this even possible in Keycloak? I must be missing something, I always get the error message that the page does not exist. Can I route to specific .ftl - files? After googling this stuff I guess it is only possible to customize existing Freemarker-Files that Keycloak is using with its logic but not extend them, add more and route to them?
Appreciate your support!
You may want to implement a custom REST endpoint (see the https://www.keycloak.org/docs/latest/server_development/#_extensions_rest for details). Within that endpoint you can lookup the LoginFormsProvider
and call createForm
method. Pass the name of the ftl file as a parameter. Then simply pass the response from that method back as a response of your REST endpoint.