<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 19 May 2016 at 20:44, Mitya <span dir="ltr">&lt;<a href="mailto:mitya@cargosoft.ru" target="_blank">mitya@cargosoft.ru</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Stian,<br>
<br>
A follow-up on realm resources - I&#39;ve stumbled upon this thread: <a href="http://lists.jboss.org/pipermail/keycloak-dev/2015-December/006100.html" rel="noreferrer" target="_blank">http://lists.jboss.org/pipermail/keycloak-dev/2015-December/006100.html</a><br>
<br>
That &quot;(coming) ability to freely extend the JPA entities and DB schema&quot; is the very same Entity SPI you were talking about, right?<br></blockquote><div><br></div><div>Yep</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I see now how to implement realm resources. It&#39;s a pity that custom<br>
admin resources (initially included into Pedro Igor&#39;s commit) were<br>
removed; these would be a fairly natural addition to the upcoming<br>
Entity SPI. Are there any plans to include that back?<br></blockquote><div><br></div><div>We plan to add it, but we&#39;d like it to have some support for authorization, which the PR didn&#39;t provide. So there was basically no difference between the two in the original PR.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
As a workaround, is it possible to install a custom realm resource<br>
(/realms/{realm}/foo), manually protect it with an authorization<br>
constraint, and use it inside admin console (as a surrogate admin<br>
resource)?<br></blockquote><div><br></div><div>Yes, that&#39;s fine. You can look at the source code for how we deal with authorization in the admin resources. Look at AdminRootResource I think it is.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
Mitya<br>
<br>
P.S. BTW, examples/providers/rest/pom.xml contains an erroneous &quot;&lt;name&gt;Authenticator Example&lt;/name&gt;&quot; inside<br>
<div class="HOEnZb"><div class="h5"><br>
&gt; Hi Stian, thanks for response!<br>
&gt;<br>
&gt; &gt; You don&#39;t strictly need to use model interface, JPA adapter, etc..<br>
&gt; &gt; You can just make it a entity directly. We have those layers<br>
&gt; &gt; because<br>
&gt; &gt; we support JPA and Mongo. <br>
&gt;<br>
&gt; thx, got it<br>
&gt;<br>
&gt; (interestingly, many IDM developers end up implementing a JDO-like<br>
&gt; engine; this has also happened to PicketLink, they supported both JPA<br>
&gt; and LDAP with a single API)<br>
&gt;<br>
&gt; &gt; At the moment you can&#39;t add custom entities to the persistence.xml<br>
&gt; &gt; without modifying it within the JAR, but we plan to introduce an<br>
&gt; &gt; Entity SPI that allows adding custom entities (we have a PR for it,<br>
&gt; &gt; it needs some work, but should be included in 2.0.0.CR1 due some<br>
&gt; &gt; time<br>
&gt; &gt; in June).<br>
&gt;<br>
&gt; Glad to hear about Entity SPI! I&#39;ll probably start with modified<br>
&gt; KeyCloak, and migrate to the SPI as soon as it&#39;s ready.<br>
&gt;<br>
&gt; &gt; We have added support for custom REST resource, but not admin<br>
&gt; &gt; resources. Main difference is how it&#39;s secured and URLs.<br>
&gt;<br>
&gt; Could you please elaborate on &quot;custom REST resources&quot;? I couldn&#39;t<br>
&gt; find<br>
&gt; anything in the docs, there is only &quot;21. Admin REST API&quot;. What are<br>
&gt; custom REST resources, how to implement them? Could they be helpful<br>
&gt; in<br>
&gt; my use case?<br>
&gt;<br>
&gt; Cheers,<br>
&gt; Mitya<br>
&gt;<br>
&gt; &gt; &gt; You&#39;d also need to modify the admin console, but that can be done<br>
&gt; &gt; with a custom theme.<br>
&gt; &gt; &gt; &gt; On 19 May 2016 at 12:36, Mitya &lt;<a href="mailto:mitya@cargosoft.ru">mitya@cargosoft.ru</a>&gt; wrote:<br>
&gt; &gt; &gt; Hi,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; My goal is to implement a custom first-class KeyCloak entity<br>
&gt; &gt; &gt; (like<br>
&gt; &gt; &gt; User, Group, etc.) Entities should persist in KeyCloak database<br>
&gt; &gt; &gt; along<br>
&gt; &gt; &gt; with Users, Groups etc.; there should be a CRUD interface in the<br>
&gt; &gt; &gt; admin<br>
&gt; &gt; &gt; console to manage them; it will have an unidirectional N:1<br>
&gt; &gt; &gt; relationship<br>
&gt; &gt; &gt; to User and will participate in authentication process. In some<br>
&gt; &gt; &gt; future,<br>
&gt; &gt; &gt; most likely it will also participate in federation (to/from<br>
&gt; &gt; &gt; external<br>
&gt; &gt; &gt; LDAP server with custom schema).<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; After briefly studying KeyCloak internals, I&#39;ve got an impression<br>
&gt; &gt; &gt; that<br>
&gt; &gt; &gt; Provider SPIs won&#39;t help me much. Seems like what I&#39;ll have to<br>
&gt; &gt; &gt; implement is at least:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; - model interface (org.keycloak.models)<br>
&gt; &gt; &gt; - entity class (org.keycloak.models.entities)<br>
&gt; &gt; &gt; - JPA adapter (org.keycloak.models.jpa)<br>
&gt; &gt; &gt; - JPA entity (org.keycloak.models.jpa.entities)<br>
&gt; &gt; &gt; - (the same for Mongo and Infinispan)<br>
&gt; &gt; &gt; - REST representation (org.keycloak.representations.idm)<br>
&gt; &gt; &gt; - REST resource (org.keycloak.services.resources.admin)<br>
&gt; &gt; &gt;  <br>
&gt; &gt; &gt; Next, there will be custom authenticator (to make use of the<br>
&gt; &gt; &gt; entity)<br>
&gt; &gt; &gt; and GUI modifications. I hope I didn&#39;t forget anything?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Important question is - can I implement all of that without<br>
&gt; &gt; &gt; modifying<br>
&gt; &gt; &gt; KeyCloak code? Maintaining a fork and producing customized builds<br>
&gt; &gt; &gt; will<br>
&gt; &gt; &gt; complicate development process a lot. Ideally, classes should<br>
&gt; &gt; &gt; reside in<br>
&gt; &gt; &gt; my own packages (not org.keycloak.*), the code should be packaged<br>
&gt; &gt; &gt; as a<br>
&gt; &gt; &gt; module (JBoss module? OSGi bundle?) and simply be plugged into an<br>
&gt; &gt; &gt; official KeyCloak build. I see forking only as a last resort,<br>
&gt; &gt; &gt; it&#39;s<br>
&gt; &gt; &gt; something I&#39;d like to avoid absolutely.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thanks!<br>
&gt; &gt; &gt; Mitya<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; keycloak-dev mailing list<br>
&gt; &gt; &gt; <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a><br>
&gt; _______________________________________________<br>
&gt; keycloak-dev mailing list<br>
&gt; <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a><br>
</div></div></blockquote></div><br></div></div>