[keycloak-user] keycloak tomcat 7 adapter

Guy Davis guydavis.ca at gmail.com
Tue Mar 31 17:06:24 EDT 2015


Hi Henk,

In your adapter configuration file, probably keycloak.json in your war's
WEB-INF folder, add the following configuration:

"principal-attribute": "preferred_username"


The docs
<http://docs.jboss.org/keycloak/docs/1.1.0.Final/userguide/html_single/#adapter-config>
describes the following choices:  sub, preferred_username, email, name,
nickname, given_name, family_name

Alternatively, if you cast your request.getPrincipal() to KeycloakPrincipal
<http://docs.jboss.org/keycloak/docs/1.1.0.Final/javadocs/org/keycloak/KeycloakPrincipal.html>,
then you should be able to get at the various attributes via the security
context. (I think...)

Hope this helps,
Guy


On Tue, Mar 31, 2015 at 2:52 PM, Henk Laracker <
Henk.Laracker at planonsoftware.com> wrote:

> Hi,
>
> I’m using the key cloak tomcat 7 adaptor, I created a sample application
> which works fine with keycloak. I created a jsp page with the following code
>
>    String username = request.getRemoteUser();
>    <tr><td>User</td><td><%= username %></td></tr>
>
>  I have logged in with the username : supervisor
>
> So I expect the username to be : supervisor
>
> But the result is :3d5bfb0c-9495-48b8-a11c-2e83097b2f39
>
>
> What do I do wrong ?
>
>
> Met vriendelijke groet / Yours sincerely / Mit freundlichen Grüßen / Très
> cordialement,
>
>
> Henk Laracker
>
>
>
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20150331/baff5e1b/attachment.html 


More information about the keycloak-user mailing list