<div dir="ltr">I went ahead, cowboy style and opened a PR for it <a href="https://github.com/keycloak/keycloak/pull/3056">https://github.com/keycloak/keycloak/pull/3056</a><div><br></div><div>Couldn&#39;t find tests so didn&#39;t add any.</div><div><br></div><div>Pires</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 21, 2016 at 12:06 PM Paulo Pires &lt;pires@littlebits.cc&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Something like this should work though:<div><br><div><div>@GET</div><div>@Produces({&quot;application/json&quot;})</div><div>@Path(&quot;default-roles&quot;)</div><div>List&lt;RoleRepresentation&gt; getDefaultRoles();</div><div><br></div><div>@PUT</div><div>@Path(&quot;default-roles/{roleId}&quot;)</div><div>void addDefaultRole(@PathParam(&quot;roleId&quot;) String roleId);</div><div><br></div><div>@DELETE</div><div>@Path(&quot;default-roles/{roleId}&quot;)</div><div>void removeDefaultRole(@PathParam(&quot;roleId&quot;) String roleId);</div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 21, 2016 at 12:03 PM Paulo Pires &lt;pires@littlebits.cc&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>It&#39;s working like a charm :)</div><div><br></div><div>Some things I learned:</div><div>* Need to import resteasy deps for keycloak-admin-cli explicitly</div><div>* Methods won&#39;t return errors but will throw InvocationTargetException (must be checked)</div><div><br></div>Question: is there a way to set default roles? I can&#39;t seem to find it in the Java code but it is available through REST.<div><br></div><div>Thanks,</div><div>Pires</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 21, 2016 at 8:47 AM Paulo Pires &lt;pires@littlebits.cc&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thank you Bruno, I haven&#39;t been able to verify your code but I assume you&#39;re sharing it because it works.<div><br></div><div>It seems pretty trivial, awesome!</div><div><br></div><div>Cheers,</div><div>Pires</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 20, 2016 at 9:30 PM Bruno Oliveira &lt;<a href="mailto:bruno@abstractj.org" target="_blank">bruno@abstractj.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Note sure if it helps, but an example about how to do it<br>
programatically is here[1].<br>
<br>
I just adapted from the admin-client[2].<br>
<br>
<br>
[1] - <a href="https://gist.github.com/abstractj/78b127e8c9273cdcea6eb82a1cfc153c" rel="noreferrer" target="_blank">https://gist.github.com/abstractj/78b127e8c9273cdcea6eb82a1cfc153c</a><br>
[2] - <a href="https://github.com/keycloak/keycloak/tree/master/examples/admin-client" rel="noreferrer" target="_blank">https://github.com/keycloak/keycloak/tree/master/examples/admin-client</a><br>
<br>
On 2016-07-20, Paulo Pires wrote:<br>
&gt; I did check the admin-cli JAR but it&#39;s not clear how to add roles and<br>
&gt; users, or if it&#39;s even implemented (I did check the REST API and there&#39;s<br>
&gt; endpoints for that).<br>
&gt;<br>
&gt; Thank you very much for clarifying,<br>
&gt; Pires<br>
&gt;<br>
&gt; On Wed, Jul 20, 2016 at 2:52 PM Stian Thorgersen &lt;<a href="mailto:sthorger@redhat.com" target="_blank">sthorger@redhat.com</a>&gt;<br>
&gt; wrote:<br>
&gt;<br>
&gt; &gt; Yep, take a look at<br>
&gt; &gt; <a href="https://keycloak.gitbooks.io/server-developer-guide/content/topics/admin-rest-api.html" rel="noreferrer" target="_blank">https://keycloak.gitbooks.io/server-developer-guide/content/topics/admin-rest-api.html</a><br>
&gt; &gt;<br>
&gt; &gt; On 20 July 2016 at 15:33, Paulo Pires &lt;pires@littlebits.cc&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt;&gt; More than 150k. Is there a Java library for the REST api?<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; On Jul 20, 2016 13:56, &quot;Stian Thorgersen&quot; &lt;<a href="mailto:sthorger@redhat.com" target="_blank">sthorger@redhat.com</a>&gt; wrote:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;&gt; Depending on the amount of users I&#39;d use either partial import through<br>
&gt; &gt;&gt;&gt; the admin console (if you don&#39;t have more than a thousand or so users) or<br>
&gt; &gt;&gt;&gt; use the admin REST endpoints if you have quite a lot of users.<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; On 20 July 2016 at 11:52, Paulo Pires &lt;pires@littlebits.cc&gt; wrote:<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; Hi all,<br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; I&#39;m in the process of migrating from an in-house user-role storage to<br>
&gt; &gt;&gt;&gt;&gt; Keycloak and I&#39;m looking for programmatic (Java) ways to migrate all<br>
&gt; &gt;&gt;&gt;&gt; current users to the new storage. And I need your help to figure out the<br>
&gt; &gt;&gt;&gt;&gt; best approach.<br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; At first, when reading KC documentation, I believed I could easily<br>
&gt; &gt;&gt;&gt;&gt; achieve this by implementing a User Federation provider but after diving a<br>
&gt; &gt;&gt;&gt;&gt; little more into it, and looking for examples, I can&#39;t see a way to migrate<br>
&gt; &gt;&gt;&gt;&gt; all users on-demand but simply one user at a time, possible during log-in.<br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; Next, I tried and look into ways, such as admin-cli, REST, etc but<br>
&gt; &gt;&gt;&gt;&gt; nothing strikes me as the solution to use.<br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; Here&#39;s what I was hoping to deliver:<br>
&gt; &gt;&gt;&gt;&gt; * Get all roles and users from my soon-to-be deprecated storage, e.g.<br>
&gt; &gt;&gt;&gt;&gt; MySQL tables<br>
&gt; &gt;&gt;&gt;&gt; * Add roles to KC<br>
&gt; &gt;&gt;&gt;&gt; * Iterate users and add user to KC + map roles + update password hashes<br>
&gt; &gt;&gt;&gt;&gt; (here I know I need to implement a HashProvider)<br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; Any hints will be appreciated!<br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; Pires<br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; _______________________________________________<br>
&gt; &gt;&gt;&gt;&gt; keycloak-user mailing list<br>
&gt; &gt;&gt;&gt;&gt; <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
&gt; &gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;<br>
<br>
&gt; _______________________________________________<br>
&gt; keycloak-user mailing list<br>
&gt; <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
&gt; <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>
abstractj<br>
PGP: 0x84DC9914<br>
</blockquote></div></blockquote></div></blockquote></div></blockquote></div>