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

Roles #7

Closed
alfreema opened this issue Mar 6, 2019 · 8 comments
Closed

Roles #7

alfreema opened this issue Mar 6, 2019 · 8 comments

Comments

@alfreema
Copy link

alfreema commented Mar 6, 2019

How can I call the underlying keycloak adapter's hasRealmRole( ) function? I am missing how to check roles with this plugin.

@nlien
Copy link
Contributor

nlien commented Mar 7, 2019

In the onReady callback, you have access to the keycloak object. You could maybe get the roles by accessing keycloak.tokenParsed['authorities'] ? Or just call the hasRealmRole function directly?

@alfreema
Copy link
Author

alfreema commented Mar 8, 2019

Okay, is there a way to access the underlying keycloak object using this.$keycloak?

@nlien
Copy link
Contributor

nlien commented Mar 8, 2019

Not yet, I'm afraid. There are certain callback functions, like onAuth*, on the keycloak object, which we'd rather not expose. Because overriding them would break the plugin's behavior. Maybe we'll expose more of the underlying object in the near future... In the meantime go for my suggestion above, or use the token from this.$keycloak.token and parse it yourself.

@nlien nlien closed this as completed Mar 8, 2019
@alfreema
Copy link
Author

I don't think I can use onReady, because no authentication has taken place at that point. I'll look into parsing this.$keycloak.token though.

@nlien
Copy link
Contributor

nlien commented Mar 12, 2019

Hi again... keycloak.tokenParsed['authorities'] may not be what you want, I realize. Behind the scenes, Keycloak's hasRealmRole function inspects the keycloak.realmAccess.roles array for the given role. If you'd still like to have the hasReamRole() exposed on the $keycloak object, I'll ship a new version with this added. Just let me know by replying here.

@nlien nlien reopened this Mar 12, 2019
@anderius
Copy link
Contributor

I vote for exposing both hasRealmRole and hasResourceRole.

@alfreema
Copy link
Author

Sorry for delayed responses, I am not in front of a computer as much as I'd like to be these days. :) I'll leave that up to you gurus, I just need a somewhat future-proof way to authorize using roles. Implementing a function that maps to hasRealmRole seems to be the easiest in my pea-sized brain.

@nlien
Copy link
Contributor

nlien commented Mar 13, 2019

Exposed hasRealmRole and hasResourceRole in v1.0.9

@nlien nlien closed this as completed Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants