How to change host in Keycloak update password email

Viewed 2091

We use Keycloak REST api to send update password email to users. In my setup Keycloak and application making REST calls to Keycloak (using keycloak admin client library) is deployed inside Kubernetes cluster. From my application I am using Kubernetes service name to talk to keycloak.

e.g. http://keycloak-http:8100/auth

With this setup, update password link in email becomes like this http://keycloak-http:8100/auth/realms/test/login-actions/action-token?key=somekey

So I need to change only host in this URL.

I looked at executeActions.ftl file in keycloak theme and it doesn't have any specific parameter for just host which I can customize.

Any ideas how I can achieve this?

Thanks in advance.

2 Answers

In my case, Keycloak 9+, I used the "Frontend URL" in the Realm Setting to specify the hostname. enter image description here

I had a similar issue, and it turns out that by default, the host name is filled with the request hostname. (Using Keycloak 6.0.1)

All i had to do was to trigger the email generation with the hostname i wanted in the email. --> Trigger the update action from the url you need (and that is accessible) http://externalurl.keycloak.com/auth/...

You can also change the hostname provider, to use a FixedHostnameProvider, or a custom one (it is RequestHostnameProvider by default) https://www.keycloak.org/docs/latest/server_installation/#_hostname

Related