Android: How can i get user's roles from Keycloak(OAuth2 Endpoint)?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Android: How can i get user's roles from Keycloak(OAuth2 Endpoint)?

Naif
Hi everyone

I checked the aerogear android cookbook, and i found the 'ShootAndShare' demo, it has interesting code in the 'KeycloakHelper.java' with some utility methods. But, i would like to know, how can i get the roles for a registered keycloak user?

Are the AuthorizationManager and AuthzModule the right classes for this task? Or, it is better to use another approach? Because, it would be necessary to retrieve more user information from Keycloak(i.e. user email, first name, etc) and to code a correct logout method.

Any ideas?

Thanks in advance.

Reply | Threaded
Open this post in threaded view
|

Re: [Aerogear-users] Android: How can i get user's roles from Keycloak(OAuth2 Endpoint)?

Summers Pittman


On Thu, Sep 3, 2015 at 10:34 AM, Naif <[hidden email]> wrote:
Hi everyone

I checked the aerogear android cookbook, and i found the 'ShootAndShare'
demo, it has interesting code in the 'KeycloakHelper.java' with some utility
methods. But, i would like to know, how can i get the roles for a registered
keycloak user?

Are the AuthorizationManager and AuthzModule the right classes for this
task? Or, it is better to use another approach? Because, it would be
necessary to retrieve more user information from Keycloak(i.e. user email,
first name, etc) and to code a correct logout method.

Any ideas?

The authz librares are mostly used to managing OAuth2 tokens and lifecycles.  One could modify the classes in the oauth2 package to handle keycloak events.  I would begin looking at Oauth2Session and Oauth2AuthzService.  The session class would add properties available from KeyCloak and the OAuth2AuthzService class would fetch these properties as part of the login lifecycle.  Everything else would probably remain relatively untouched.

This sounds like an amazing opportunity for some refactoring or adding pluggability to the lifecycle.

TL;DR; yes those are good interfaces to look at.


 

Thanks in advance.





--
View this message in context: http://aerogear-users.1116366.n5.nabble.com/Android-How-can-i-get-user-s-roles-from-Keycloak-OAuth2-Endpoint-tp230.html
Sent from the aerogear-users mailing list archive at Nabble.com.
_______________________________________________
Aerogear-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-users


_______________________________________________
Aerogear-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/aerogear-users
Reply | Threaded
Open this post in threaded view
|

Re: [Aerogear-users] Android: How can i get user's roles from Keycloak(OAuth2 Endpoint)?

Naif
OAuth2AuthzSession is a parcelable with properties, i don't have a key idea of how, after adding the properties there, how to fetch Keycloak properties in the OAuth2AuthzService class; i would like to have some algorithm with the key objects to implement that functionality. Could you please write some steps to follow? I do not have a clear idea about this.