Jonas Kreusch
Jonas Kreusch

Reputation: 354

How to set the redirect uri for keycloak using spring

I'm using the keycloak spring boot adapter (not the spring security adapter) secure my application i.e. manage logins. I deployed my application to http://my.company.host.com/client1 and added this uri as the root url, the valid redirect uri and the base url in the keycloak client that my application uses. When i access the application, i'm redirected to keyclaok as expected. Keycloak gives me the invalid redirect uri error. I checked the browsers dev tools to see that spring is sending me to keycloak with http://my.company.host.com as the redirect uri instead of http://my.company.host.com/client1. So throwing the invalid redirect uri makes sense but why does spring not use the root url i provided i.e. throws away the path. In spring i only configure keycloak in the application.properties file. The documentation does not list a config field "redirect uri"

Upvotes: 0

Views: 1327

Answers (2)

Jonas Kreusch
Jonas Kreusch

Reputation: 354

So turns out my organization is using a reverse proxy to map the paths of the server to the individual applications. This reverse proxy was removing the deployment path from requests so that the applications could handle them normally. In other words the applications can then receive requests in their root path instead of having to handle the deployment prefix path.

Upvotes: 0

Viettel Solutions
Viettel Solutions

Reputation: 1489

You config Valid Redirect URIs in client config on Keycloak yet ?

If you had config, I think you should deploy your application to http://my.company.host.com then update config base URL on Keycloak to http://my.company.host.com and try again !

Upvotes: 0

Related Questions