<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div>How about wrapping <span style="font-size: 12pt;">your application under a filter (or a valve in JBoss or Tomcat) ? From there you could populate your authenticated subject (or the session?) with whatever information your keycloak token could provide.</span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">Would that be a good idea ?</span></div><div><span style="font-size: 12pt;"><br></span></div><div><hr id="stopSpelling">Date: Wed, 28 Oct 2015 05:01:17 -0700<br>From: sthorger@redhat.com<br>To: tdudgeon.ml@gmail.com<br>CC: keycloak-user@lists.jboss.org<br>Subject: Re: [keycloak-user] Accessing authenticated user's details<br><br><div dir="ltr">Yes, JavaEE currently has no standard way of obtaining a user profile.</div><div class="ecxgmail_extra"><br><div class="ecxgmail_quote">On 28 October 2015 at 04:17, Tim Dudgeon <span dir="ltr"><<a href="mailto:tdudgeon.ml@gmail.com" target="_blank">tdudgeon.ml@gmail.com</a>></span> wrote:<br><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex;">
<div>
So if I understand correctly the only way to handle multiple
attributes of the user (e.g name and email) is to use the Keycloak
IDToken approach and so be dependent on the Keycloak implementation
(or create my own API that wraps this)?<span class="ecxHOEnZb"><font color="#888888"><br>
<br>
Tim <br></font></span><div><div class="h5">
<br>
<div>On 26/10/2015 09:24, Marek Posolda
wrote:<br>
</div>
<blockquote>
<div>If you don't want Keycloak
dependencies, you can use request.getRemoteUser() or
request.getPrincipal().getName() to access just the userId of
authenticated user. If you use "principal-attribute" in
keycloak.json, it will return the configured attribute instead
of userId, so you can receive for example username or email
instead. But that way, you will be able to access just this
single attribute.<br>
<br>
Marek<br>
<br>
On 26/10/15 09:52, Tim Dudgeon wrote:<br>
</div>
<blockquote>
Wondered if anyone had any thoughts on this?<br>
<br>
<div>On 21/10/2015 12:04, Tim Dudgeon
wrote:<br>
</div>
<blockquote>
In the case of a web application (e.g. Tomcat app secured by
the keycloak adapter) the web app might need to access details
of the authenticated user (e.g. full name or email).<br>
I've found that this information is available from the session
like this: <br>
<br>
<small><tt>KeycloakSecurityContext session =
(KeycloakSecurityContext)request.getAttribute(KeycloakSecurityContext.class.getName());</tt><tt><br>
</tt><tt>IDToken idToken = session.getIdToken();</tt><tt><br>
</tt><tt>String email = idToken.getEmail();</tt></small><br>
<br>
One issue with this is that all your web apps are tied to
keycloak.<br>
<br>
Is this the right way to handle this?<br>
Are there alternatives?<br>
<br>
Tim<br>
<br>
</blockquote>
<br>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
keycloak-user mailing list
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></pre>
</blockquote>
<br>
</blockquote>
<br>
</div></div></div>
<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></blockquote></div><br></div>
<br>_______________________________________________
keycloak-user mailing list
keycloak-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user</div>                                            </div></body>
</html>