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

Using interceptor doesn't allow anonymous users #162

Closed
Mawi137 opened this issue Oct 1, 2019 · 1 comment
Closed

Using interceptor doesn't allow anonymous users #162

Mawi137 opened this issue Oct 1, 2019 · 1 comment
Labels
enhancement This issue/PR is an enhancement or new feature.
Milestone

Comments

@Mawi137
Copy link
Contributor

Mawi137 commented Oct 1, 2019

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search for issues before submitting
- [x ] feature request

Versions.

angular: 8.0.3
keycloak-angular: 7.0.1
keycloak-js: 4.8.3

Repro steps.

Enable keycloak bearer interceptor.
If the user is not logged in and a call is made to the backend where a bearer can be added, then the user is redirected to the login page.

Desired functionality.

I have an endpoint that can be called by anonymous as well as logged in users. Depending on the ID they pass, they can have anonymous access or need to be logged in. The problem is that the http interceptor provided by this lib always forces the user to login when enableBearerInterceptor is set to true. I added my own interceptor for now, but I'm willing to create a PR for this if you agree that the access token should only be added to the request when the user is actually logged in. It could also be an option in the KeycloakOptions.

@mauriciovigolo mauriciovigolo added Priority: Medium enhancement This issue/PR is an enhancement or new feature. labels Oct 7, 2019
@mauriciovigolo
Copy link
Owner

Hi @Mawi137. Thanks for the issue and indeed this is a problem in the actual implementation. I'm working on the new version of the library and I'm changing a little bit the interceptor configurations.

The idea of adding the access token only if the user is logged in is great and we could add it on the current version, just the configuration on KeycloakOptions part maybe could be left for now. Your PR is very welcomed.

Thank you!

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

No branches or pull requests

2 participants