DrTeeth
DrTeeth

Reputation: 1317

How can I maintain redirect_uri through registration in Keycloak?

Running Keycloak v25. Created a realm and a client, and everything works fine from my application if the user is already registered. Specifically, after authentication they are brought back to my app via the redirect_uri I pass in the initial handshake.

I want to allow users to self register, and allow them to use the forgot password email functionality. Both take the user outside of the normal auth flow, and they are dropped back into my app at the (base URL) configured for the client.

This doesn't really work if (for instance) they are coming in from a mobile app. They are then dropped into a mobile web experience instead of the app. It's also just clunky to not have them be taken back to the page they wanted.

Explicitly:

To log in, the user is brought to

https://login.my.domain/realms/TestRealm/protocol/openid-connect/auth?response_type=code&client_id=TestClient&scope=openid%20email%20offline_access&redirect_uri=https://app.my.domain/redirect&state=...

As soon as they click on "register new user", they are brought to

https://login.my.domain/realms/TestRealm/login-actions/registration?client_id=TestClient&tab_id=...&client_data=...

The redirect_uri is lost. Even if Keycloak somehow maintains it, it doesn't seem to make it into the URL sent in the registration email that completes the registration.

So... Is there any way to maintain the original redirect_uri through the registration and forgot email processes?

Upvotes: 1

Views: 283

Answers (1)

DrTeeth
DrTeeth

Reputation: 1317

As hinted at by this, the original redirect_uri is maintained in the client_data hash. I've re-tested this and that is preserved through the new user registration process, so not sure what I messed up in the original test. This should all work as intended.

Upvotes: 1

Related Questions