redirect_uri with # has wrong redirect
See original GitHub issueDescribe the bug
When request endpoint /auth/realms/realm-name/protocol/openid-connect/auth
with # on url, the redirect merge querystring and hash params.
Nowadays is common SPA applications use # on URL to make hash-based routing
Impact
The only safe way to use keycloak-js is to initialize before any router behavior.
- It impossible to use bundle size on keycloak stuff
- create an instance of keycloak in pages that are not necessarily needed.
Version
15.0.2
Expected behavior
Redirect with query string, and hash independently
curl 'https://keycloak-url/auth/realms/realm-name/protocol/openid-connect/auth?client_id=clientId&redirect_uri=https%3A%2F%2Fapplication-url%2F%23%2Finternal%2Furl&state=secret-state&response_mode=fragment&response_type=code&scope=openid&nonce=secret-nonce&prompt=none' -H 'cookie: cookies' -i
HTTP/2 302
date: Mon, 29 Nov 2021 19:47:43 GMT
content-length: 0
location: https://application-url/#/internal/url?state=secret-state&session_state=secret-session&code=secret-code
Actual behavior
Redirect with query string, and hash merged independently
> curl 'https://keycloak-url/auth/realms/realm-name/protocol/openid-connect/auth?client_id=clientId&redirect_uri=https%3A%2F%2Fapplication-url%2F%23%2Finternal%2Furl&state=secret-state&response_mode=fragment&response_type=code&scope=openid&nonce=secret-nonce&prompt=none' -H 'cookie: cookies' -i
HTTP/2 302
date: Mon, 29 Nov 2021 19:47:43 GMT
content-length: 0
location: https://application-url/#/internal/url&state=secret-state&session_state=secret-session&code=secret-code
How to Reproduce?
Request auth/realms/realm-name/protocol/openid-connect/auth
with valid params, example with mocked params:
curl 'https://keycloak-url/auth/realms/realm-name/protocol/openid-connect/auth?client_id=clientId&redirect_uri=https%3A%2F%2Fapplication-url%2F%23%2Finternal%2Furl&state=secret-state&response_mode=fragment&response_type=code&scope=openid&nonce=secret-nonce&prompt=none' -H 'cookie: cookies' -i
Anything else?
More about hash router: https://krasimirtsonev.com/blog/article/deep-dive-into-client-side-routing-navigo-pushstate-hash
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:7
Top Results From Across the Web
redirect uri returns wrong uri - Microsoft Q&A - Microsoft Learn
I have configured 2 redirect uri for 2 different environments ... I can see that the location header in devtools has the wrong...
Read more >Google OAuth 2 authorization - Error: redirect_uri_mismatch
The redirect URI (where the response is returned to) has to be registered in the APIs console, and the error is indicating that...
Read more >Redirect_uri seems to be wrong - Auth0 Community
Hi, Please see the application I have setup in " Salesforce OpenId Connect 2" app for authenticating users login from salesforce application ...
Read more >Invalid redirect uri but redirect uri are configured in client
Hi! I'm configuring a client for SSO in Google Workspace using Keycloak as IDP. Everything is working fine with the exception of logout....
Read more >The 'redirect_uri' parameter must be a Login redirect URI in ...
This error is returned because the value of ${redirect_uri} used in authorize request is not registered in the Open ID client in Okta,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s just that your problem is solved. It also works with the
Valid Redirect URI
field set to*
.This bug is still there. It’s a different bug.
We are using Keycloak 16.1.0. Suffering from this bug.