Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to login by incorrect redirect url. #9

Open
rockyfaninus opened this issue Jun 11, 2017 · 3 comments
Open

Failed to login by incorrect redirect url. #9

rockyfaninus opened this issue Jun 11, 2017 · 3 comments

Comments

@rockyfaninus
Copy link

Hi team:
There is an issue on login redirect url.
Repro:

Create ember new project.
Add route: help.
In the routes/application.js, init keycloak, but set it as "session.set('onLoad', 'check-sso');", allow user not logged in at home page.
Update routes/help.js, add KeycloakAuthenticatedRouteMixin to require user login.
Note: At this point, it looks works. When open http://www.sample.com:4200/help, it redirect to keycloak login page and a user is able to log in.

Issue was start at:

when I update the environment.js, set as follows:
rootURL: '/test',
locationType: 'hash',

When open the site like www.sample.com:4200/test/#/help, it redirects to keycloak login page. But the keycloak login page return error: "Invalid parameter: redirect_uri".

The failure was caused by the redirect URL was set as: http://www.sample.com:4200#help.
It is wrong, the correct one should be http://www.sample.com:4200/test/#/help. The rootURL was missing.

Please help to take look and fix the issue. Thanks.

@rfplayus
Copy link
Contributor

Hi:
I tried to direct use keycloak.js adapter from keycloak server (version of Keycloak 3.1.0.final), without install ember-keycloak-auth, when calling keycloak login() without argument, and found it works fine. (for /test/#/help)

So I copy keycloak-session.js to my project and update the code, remove the argument 'url' from keycloak-session.login(url), it works for both locationType as 'hash' or 'auto'. It looks like keycloak.js can handle the redirect url. So we don't need to give it a redirect url.

It is a good feature if we can control the logged-url when calling login(url) method. But when the caller did not passed into 'redirect url', instead to generate redirect url, I think it is better to leave it as empty and let the keycloak to handle it.

@Buchnekromant
Copy link

I was able to hunt down the error to the keycloak-session.js.
In the _parseRedirectUrl function, the URL is concatinated with the window.location.origin.
return "".concat(window.location.origin).concat(url);
For routing with locationType "history" thats probably fine.
But with locationType "hash" the URL part for example is #/login, the origin is http://localhost:4200 and both together result in http://localhost:4200#/login with a missing slash in front of the #.
image

@beastmst
Copy link

beastmst commented Jul 5, 2019

any update for this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants