<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Marek,<div class=""><br class=""></div><div class="">Thank you. That did the trick!</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Scott</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 17, 2015, at 6:20 AM, Marek Posolda <<a href="mailto:mposolda@redhat.com" class="">mposolda@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" class="">
<div bgcolor="#FFFFFF" text="#000000" class="">
<div class="moz-cite-prefix">Hi,<br class="">
<br class="">
you should use method "userModel.grantRole(role)" to add new role
mapping. Methods "getRoleMappings" and "getRealmRoleMappings" are
used just for reading existing role mappings of user.<br class="">
<br class="">
Marek<br class="">
<br class="">
On 15.6.2015 16:49, Scott Rossillo wrote:<br class="">
</div>
<blockquote cite="mid:4154AAD4-3C42-422B-8FD5-FAA21732B91B@smartling.com" type="cite" class="">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252" class="">
Hey all,
<div class=""><br class="">
</div>
<div class="">I was going to create a JIRA for this, but just want
to make sure it’s an actual bug. We are not able to assign roles
to a user from a federation provider.</div>
<div class=""><br class="">
</div>
<div class="">For example, we expected something like this to work
from UserFederationProvider. getUserByUsername(RealmModel realm,
String username):</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; font-family: Menlo;
color: rgb(102, 102, 102);" class=""> if
(remoteUser.getRoles() != null) {</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;
color: rgb(102, 102, 102);" class=""> for (String
roleName : remoteUser.getRoles()) {</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;
color: rgb(102, 102, 102);" class=""> RoleModel
role = realm.getRole(roleName);</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;
color: rgb(102, 102, 102);" class="">
userModel.getRoleMappings().add(role); // doesn’t work</div>
<div style="margin: 0px;" class=""><span style="color: rgb(102,
102, 102); font-family: Menlo; font-size: 11px;" class="">
</span><span style="color: rgb(102, 102, 102);
font-family: Menlo; font-size: 11px;" class=""> </span><font class="" color="#666666" face="Menlo"><span style="font-size: 11px;" class="">userModel.getRealmRoleMappings().add(role); </span></font><span style="color: rgb(102, 102, 102); font-family: Menlo;
font-size: 11px;" class="">// doesn’t work</span></div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;
color: rgb(102, 102, 102);" class=""> }</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;
color: rgb(102, 102, 102);" class=""> }</div>
</div>
<div class=""><br class="">
</div>
<div class="">However, nothing but the default role is assigned
even when we confirm additional roles are assigned to remoteUser
and realm.getRole() returns a valid RoleModel.</div>
<div class=""><br class="">
</div>
<div class="">Create JIRA or should we be assigning roles from a
UserFederationProvider in another way?</div>
<div class=""><br class="">
</div>
<div class="">Thanks</div>
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br class="">
<pre wrap="" class="">_______________________________________________
keycloak-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/keycloak-dev">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a></pre>
</blockquote>
<br class="">
</div>
</div></blockquote></div><br class=""></div></body></html>