[keycloak-user] retrieving custom user attributes

Bill Burke bburke at redhat.com
Wed Sep 30 11:30:13 EDT 2015


What do you want for an interface?  KeycloakSecurityContext has the 
unmarshalled IDToken and AccessToken.

KeycloakPrincipal.getKeycloakSecurityContext().getToken()

On 9/30/2015 11:12 AM, Arjan Lamers wrote:
> Hi,
>
> I am trying to find an easy way to access custom attributes as defined
> for a client. For a Keycloak client, I’ve defined a new Mapper for a
> /user attribute/ to store some additional authorisation data. This then
> is managed by some user domain that uses the keycloak-admin-client to
> write that property.
>
> The problem arises when I want to access that property in an JEE
> application.The way I do it right now to use the KeycloakPrincipal found
> in the javax.ejb.SessionContext. From there, I get the JWT token as a
> String, deserialize the JSON and access the custom attribute from there.
> This feels like a very roundabout way to get to the token but somehow I
> am not able to find an easier way. Is it a missing feature or is it
> simply too close to the weekend for me ;)?
>
> See
> http://www.first8.nl/blog/security-with-microservices-programmatic-security-with-keycloak/ for
> a blog post with more details.
>
> Thanks and kind regards,
> Arjan Lamers
>
> --
> Met vriendelijke groet,
>
> Arjan Lamers
> ---------------------------------------------------------------------------------------
> “God in his wisdom made the fly / And then forgot to tell us why. ”
> - Ogden Nash
>
> First Eight BV
> KvK dossiernr: 30.17.95.44
> Gemeente Utrecht
> Kerkenbos 10-59b
> 6546 BB  Nijmegen
>
> T: 024-3483570
> F: 024-3483571
> E: a.lamers at first8.nl <mailto:a.lamers at first8.nl>
> W: www.first8.nl <http://www.first8.nl>
>
> Op alle offertes, aanbiedingen of overeenkomsten van First Eight BV
> zijn, tenzij expliciet anders overeengekomen, de Algemene Voorwaarden
> van Conclusion B.V. van toepassing, welke zijn te vinden op
> www.conclusion.nl <http://www.conclusion.nl/>. Tevens zijn deze
> gedeponeerd bij de Kamer van Koophandel Midden-Nederland onder nummer
> 16059253. Op schriftelijk verzoek zullen de Algemene Voorwaarden u
> kosteloos worden toegezonden.
>
> De inhoud van dit e-mailbericht is uitsluitend bestemd voor de
> geadresseerde(n). Gebruik van de inhoud daarvan door anderen of
> verzending aan anderen is zonder toestemming van de afzender of
> geadresseerde(n) onrechtmatig. Mocht dit e-mailbericht ten onrechte bij
> u terechtgekomen zijn, dan verzoeken wij u onmiddellijk contact met ons
> op te nemen. First Eight BV betracht de grootst mogelijke zorgvuldigheid
> bij het voorkomen van virussen in de bijlage(n) bij dit bericht.
> Desondanks dient u zelf de bijlage(n) te controleren op de aanwezigheid
> van virussen en kan First Eight BV niet aansprakelijk worden gehouden
> indien bijlage(n) schade, waaronder schade aan computer(systeem),
> veroorzaken.
>
>
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com


More information about the keycloak-user mailing list