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

Implicit Flow Checks Non-Existing Refresh Token #76

Closed
jdmaguire opened this issue Jun 7, 2018 · 3 comments
Closed

Implicit Flow Checks Non-Existing Refresh Token #76

jdmaguire opened this issue Jun 7, 2018 · 3 comments
Assignees
Labels
bug This issue/PR is a bug.
Milestone

Comments

@jdmaguire
Copy link

jdmaguire commented Jun 7, 2018

Hello, I'm integrating keycloak-angular into an existing Angular 5 app and am experiencing an issue when using the implicit flow. (I'm new to keycloak and this library so it's entirely possible I've not configured something properly or misunderstood use cases.)

From a behaviour prospective, after initializing the keycloak.service, I am forwarded to the Keycloak login page and after login, successfully land back in my app. The app loads up, initializes the keycloak.service again; however, soon I find that the browser tries to navigate back to keycloak, keycloak redirects to my app, app to keycloak, keycloak back to app, and so forth.

Debugging my code, I see both isLoggedIn() and getToken() call updateToken which calls keycloak-js's updateToken which returns an error'd promise since there are no refresh tokens in an implicit flow.

I'm extending from keycloak-auth-guard.service and using the interceptor. The former calls isLoggedIn() directly in canActivate(...) and the latter calls addTokenToHeader() that then calls getToken().

I'm wondering what I'm doing wrong in the init or general usage that is causing this unexpected behaviour? Any help would be appreciated, thanks :)

Config

Using keycloak-angular 1.4.0 whose using keycloak-js 3.4.3. Example config used for init.

{
    "initOptions": {
        "responseMode": "fragment",
        "flow": "implicit",
        "onLoad": "check-sso"
    },
    "config": {
        "realm": "aRealm",
        "url": "https://example.com",
        "clientId": "clientId"
    }
}
@jdmaguire jdmaguire changed the title Questions Implicit Flow [Question] Implicit Flow Checks Non-Existing Refresh Token Jun 7, 2018
@mauriciovigolo mauriciovigolo self-assigned this Jun 12, 2018
@mauriciovigolo mauriciovigolo added the bug This issue/PR is a bug. label Jun 12, 2018
@mauriciovigolo mauriciovigolo added this to the v.4.0.0-beta.5 milestone Jun 12, 2018
@mauriciovigolo
Copy link
Owner

@jdmaguire, I was able to reproduce your issue and you are right, when using the implicit flow the behavior should be different, otherwise it will face an endless redirect loop.

Thanks for opening this issue!

@mauriciovigolo mauriciovigolo changed the title [Question] Implicit Flow Checks Non-Existing Refresh Token Implicit Flow Checks Non-Existing Refresh Token Jun 12, 2018
mauriciovigolo added a commit that referenced this issue Jun 26, 2018
- Avoid the token update when the implicit flow is chosen.
- It will perform a silent refresh as planned in issue #43.
mauriciovigolo added a commit that referenced this issue Jun 26, 2018
- Fix the user profile not loaded as described in issue #62.
- Silent refresh bool set was not right, dealing undefined #76.
@mauriciovigolo
Copy link
Owner

Versions 1.4.1, 2.0.2, 3.0.2 and 4.0.0 includes the fix for this bug. Thanks @jdmaguire!

@jdmaguire
Copy link
Author

Thanks for the fix. Works like a charm Mauricio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants