<div dir="ltr">Hello Jeremy,<div><br></div><div>have a look at this issue: <a href="https://issues.jboss.org/browse/KEYCLOAK-2079?jql=project%20%3D%20KEYCLOAK%20AND%20status%20%3D%20Open%20AND%20text%20~%20%22installation%22">https://issues.jboss.org/browse/KEYCLOAK-2079?jql=project%20%3D%20KEYCLOAK%20AND%20status%20%3D%20Open%20AND%20text%20~%20%22installation%22</a></div><div><br></div><div>Cheers,</div><div>Thomas</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-10 14:56 GMT+01:00 Jeremy Simon <span dir="ltr"><<a href="mailto:jeremy@jeremysimon.com" target="_blank">jeremy@jeremysimon.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So, this is nice that it can be fixed by hand. I'm wondering, is<br>
there any way to configure these things for a particular client or<br>
realm so that when you're downloading the keycloak.json from the admin<br>
console that it's present?<br>
jeremy<br>
<a href="mailto:jeremy@jeremysimon.com">jeremy@jeremysimon.com</a><br>
<a href="http://www.JeremySimon.com" rel="noreferrer" target="_blank">www.JeremySimon.com</a><br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, Feb 9, 2016 at 3:44 PM, Jeremy Simon <<a href="mailto:jeremy@jeremysimon.com">jeremy@jeremysimon.com</a>> wrote:<br>
> That's the trick! Thank you!<br>
> jeremy<br>
> <a href="mailto:jeremy@jeremysimon.com">jeremy@jeremysimon.com</a><br>
> <a href="http://www.JeremySimon.com" rel="noreferrer" target="_blank">www.JeremySimon.com</a><br>
><br>
><br>
> On Tue, Feb 9, 2016 at 3:25 PM, Thomas Darimont<br>
> <<a href="mailto:thomas.darimont@googlemail.com">thomas.darimont@googlemail.com</a>> wrote:<br>
>> Hello Jeremy,<br>
>><br>
>> try adding: "principal-attribute": "preferred_username" to your<br>
>> keycloak.json.<br>
>><br>
>> See:<br>
>> <a href="http://keycloak.github.io/docs/userguide/keycloak-server/html/ch08.html#adapter-config" rel="noreferrer" target="_blank">http://keycloak.github.io/docs/userguide/keycloak-server/html/ch08.html#adapter-config</a><br>
>><br>
>> Cheers,<br>
>> Thomas<br>
>><br>
>> 2016-02-09 20:47 GMT+01:00 Jeremy Simon <<a href="mailto:jeremy@jeremysimon.com">jeremy@jeremysimon.com</a>>:<br>
>>><br>
>>> Hi,<br>
>>><br>
>>> I can't seem to get my user's name using the keycloak adaptor for<br>
>>> spring security. I have a rest controller that i'm trying this chunk<br>
>>> of code:<br>
>>><br>
>>> ...<br>
>>> Authentication KeyCloakAuth =<br>
>>> SecurityContextHolder.getContext().getAuthentication();<br>
>>> KeycloakAccount keyAccount = ((KeycloakAuthenticationToken)<br>
>>> KeyCloakAuth).getAccount();<br>
>>><br>
>>> String username1 = keyAccount.getPrincipal().getName()<br>
>>> String username2 =<br>
>>> SecurityContextHolder.getContext().getAuthentication().getName()<br>
>>><br>
>>> KeycloakPrincipal<?> prince = (KeycloakPrincipal<?>)<br>
>>> ((KeycloakAuthenticationToken) KeyCloakAuth).getPrincipal();<br>
>>> String username3 = prince.getName();<br>
>>><br>
>>> ...<br>
>>><br>
>>><br>
>>> username1, username2, username3 will have something like this:<br>
>>> aa5f6e42-9463-4862-a750-bd0c092daf11<br>
>>><br>
>>><br>
>>> I gleaned this from some stackoverflow examples that claimed these<br>
>>> approached worked... There something I don't have set right?<br>
>>><br>
>>><br>
>>> jeremy<br>
>>> <a href="mailto:jeremy@jeremysimon.com">jeremy@jeremysimon.com</a><br>
>>> <a href="http://www.JeremySimon.com" rel="noreferrer" target="_blank">www.JeremySimon.com</a><br>
>>> _______________________________________________<br>
>>> keycloak-user mailing list<br>
>>> <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
>>> <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> keycloak-user mailing list<br>
>> <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</div></div></blockquote></div><br></div>