[keycloak-user] Obtaining the user name from the security context

Gary Brown gbrown at redhat.com
Thu Nov 20 05:25:22 EST 2014


Hi

Thanks for the information.

However, I've tried it without success - I also tried using this attribute in the keycloak unconfigured-demo and preconfigured-demo examples for customer-app/product-app, and didn't have an effect on them either.

Just wondering whether the text in the doc "OpenID Connection ID Token attribute to populate the UserPrincipal name with" implies that this attribute only works for OpenID?

With the unconfigured version, it wasn't clear whether this attribute would be set under the realm or secure-deployment elements, so initially I tried just under the realm but then eventually defined the attribute under both. Attached the wildfly standalone-full.xml.

Regards
Gary

----- Original Message -----
> If you have 1.1.0.Beta1, you can try to use "principal-attribute" with
> value "|preferred_username" in the configuration of your adapter. More
> info in |http://docs.jboss.org/keycloak/docs/1.1.0.Beta1/userguide
> /html/ch07.html#adapter-config .
> 
> It should also work to cast getUserPrincipal() to KeycloakPrincipal and
> use something like:
> 
> ((KeycloakPrincipal)getUserPrincipal()).getKeycloakSecurityContext().getToken().getPreferredUsername()
> 
> this should also work on older versions, but your code may need to have
> dependencies on keycloak.
> 
> Marek
> 
> On 19.11.2014 17:20, Gary Brown wrote:
> > Hi
> >
> > When I access getUserPrincipal().getName() in
> > javax.ws.rs.core.SecurityContext I get the UID.
> >
> > Is it possible to obtain the actual user name?
> >
> > Regards
> > Gary
> > _______________________________________________
> > keycloak-user mailing list
> > keycloak-user at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/keycloak-user
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: standalone-full.xml
Type: application/xml
Size: 30314 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/keycloak-user/attachments/20141120/8ccc4011/attachment-0001.rdf 


More information about the keycloak-user mailing list