<div dir="ltr">-1 To adding rest endpoints to the root level. I&#39;d like to get rid of &#39;realms&#39; part as some point and have all rest endpoints sit underneath a realm. This makes sure the KeycloakSession always knows what realm is being handled, so we don&#39;t need to pass the realm around as it can be retrived from the KeycloakContext. It also means that the url can be shortened as we can drop the &#39;realms&#39; part.</div><div class="gmail_extra"><br><div class="gmail_quote">On 8 December 2015 at 10:22, Greg Jones <span dir="ltr">&lt;<a href="mailto:gregj@thesoftwarecottage.com.au" target="_blank">gregj@thesoftwarecottage.com.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+1 for these changes. We have been looking at a way to add custom REST endpoints and would be happy to use this approach.<br>
<br>
Regards<br>
<span class="HOEnZb"><font color="#888888">Greg Jones<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
&gt; On 8 Dec 2015, at 8:17 PM, Erik Mulder &lt;<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Pedro&#39;s change (see below) is kindof what I was looking for, but for my case and for general flexibility I think it&#39;s good to also have a more basic point to hook into the REST API&#39;s.<br>
&gt; I implemented and tested my own suggestion of having an SPI to be able to add a REST resource at the root level. Combined with the (coming) ability to freely extend the JPA entities and DB schema, I think this creates a really powerful extensibility to Keycloak. When we finish these changes, I can write a blog post about what we did, why and how as a showcase for custom extensions to Keycloak.<br>
&gt;<br>
&gt; So are the Keycloak dev&#39;s open to a PR with a new SPI that enables you to add custom REST paths?<br>
&gt; For example, you could create something like:<br>
&gt; <a href="http://localhost:8080/auth/myPath/myResource" rel="noreferrer" target="_blank">http://localhost:8080/auth/myPath/myResource</a><br>
&gt;<br>
&gt;<br>
&gt; -----Oorspronkelijk bericht-----<br>
&gt; Van: Pedro Igor Silva [mailto:<a href="mailto:psilva@redhat.com">psilva@redhat.com</a>]<br>
&gt; Verzonden: maandag 7 december 2015 22:18<br>
&gt; Aan: Erik Mulder &lt;<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>&gt;<br>
&gt; Onderwerp: Re: [keycloak-dev] Add custom REST paths? New SPI?<br>
&gt;<br>
&gt; It is part of a working in progress around fine-grained authorization [1].<br>
&gt;<br>
&gt; The new SPI changes [2] specific to Keycloak are located in a specific branch [3] in my Keycloak fork.<br>
&gt;<br>
&gt; I need to discuss these changes with Bill and see what he thinks about it. Depending on his feedback, I can prepare a PR and send these changes to upstream.<br>
&gt;<br>
&gt; [1] <a href="https://github.com/pedroigor/keycloak-authz" rel="noreferrer" target="_blank">https://github.com/pedroigor/keycloak-authz</a><br>
&gt; [2] <a href="https://github.com/pedroigor/keycloak/commit/5e99614aacb70f7840a5ae25cfeaf3fc9d74ac54" rel="noreferrer" target="_blank">https://github.com/pedroigor/keycloak/commit/5e99614aacb70f7840a5ae25cfeaf3fc9d74ac54</a><br>
&gt; [3] <a href="https://github.com/pedroigor/keycloak/tree/keycloak-authz-modified" rel="noreferrer" target="_blank">https://github.com/pedroigor/keycloak/tree/keycloak-authz-modified</a><br>
&gt;<br>
&gt; Regards.<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt; From: &quot;Erik Mulder&quot; &lt;<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>&gt;<br>
&gt; To: &quot;Pedro Igor Silva&quot; &lt;<a href="mailto:psilva@redhat.com">psilva@redhat.com</a>&gt;<br>
&gt; Sent: Monday, December 7, 2015 5:51:26 PM<br>
&gt; Subject: RE: [keycloak-dev] Add custom REST paths? New SPI?<br>
&gt;<br>
&gt; Great, that&#39;s probably all we need!<br>
&gt; I&#39;d like to try it out, but I cannot find any reference to what you mention on Github. Is it (going to be) a pull request? Is it going to be part of a future release?<br>
&gt; Can you point me to / provide me with these changes so I can give it a spin? Thanks!<br>
&gt;<br>
&gt; ________________________________________<br>
&gt; Van: Pedro Igor Silva [<a href="mailto:psilva@redhat.com">psilva@redhat.com</a>]<br>
&gt; Verzonden: maandag 7 december 2015 16:03<br>
&gt; Aan: Erik Mulder<br>
&gt; CC: <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt; Onderwerp: Re: [keycloak-dev] Add custom REST paths? New SPI?<br>
&gt;<br>
&gt; I&#39;ve done something at this regard, where you can use a SPI in order to plug additional APIs for:<br>
&gt;<br>
&gt;    * Realm Admin RESTFul API (eg.: used by admin console)<br>
&gt;    * Realm RESFTFul API (eg.: to plug additional endpoints for realms)<br>
&gt;<br>
&gt; The two Provider interfaces are very simple and just provide a single method:<br>
&gt;<br>
&gt;    Object getResource(String pathName);<br>
&gt;<br>
&gt; Where pathName is the path that must be resolved to your custom JAX-RS resource.<br>
&gt;<br>
&gt; The factories are also very simple and allows you to build those resources for the current Realm and KeycloakSession. Eg.:<br>
&gt;<br>
&gt; RealmResourceProvider create(RealmModel realm, KeycloakSession keycloakSession);<br>
&gt;<br>
&gt; Do you need something other than that ?<br>
&gt;<br>
&gt; Regards.<br>
&gt; Pedro Igor<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt; From: &quot;Erik Mulder&quot; &lt;<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>&gt;<br>
&gt; To: <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt; Sent: Monday, December 7, 2015 12:46:39 PM<br>
&gt; Subject: [keycloak-dev] Add custom REST paths? New SPI?<br>
&gt;<br>
&gt; As some of you might know, our team is busy adding data to the keycloak system to incorporate some custom authorization information in the access token.<br>
&gt; So far we&#39;ve successfully extended the JPA entities, Liquibase table definitions and added a custom mapper to put that data in the access token. All of this without custom modifications to the original keycloak sources. This is working great, thanks for the support so far!<br>
&gt; I know I&#39;ve promised some PR&#39;s for this and they will come, but first we&#39;d like to get everything fully working, so we know it&#39;s a well functioning whole.<br>
&gt;<br>
&gt; The last piece of the puzzle is extending the REST services to include CRUD actions for our custom resources. I&#39;ve been looking into the way RESTEasy/JAX-RS works and it seems to me that in the current implementation there is no way to add extra paths. As I see it now, the KeycloakApplication class will register some singletons in it&#39;s constructor and that&#39;s that. No way to extend or to &#39;interfere&#39; there.<br>
&gt;<br>
&gt; So my question is: is there any &#39;official&#39; way to add extra REST paths to Keycloak?<br>
&gt;<br>
&gt; If not, is it an idea to add this as a new SPI? The current code for adding root paths in the KeycloakApplication constructor lists:<br>
&gt;<br>
&gt;        singletons.add(new ServerVersionResource());<br>
&gt;        singletons.add(new RealmsResource());<br>
&gt;        singletons.add(new AdminRoot());<br>
&gt;<br>
&gt; So just plain contructor calls. That seems like an easy target for &#39;SPI-ing&#39; :-).<br>
&gt; Or just leave the current ones &#39;hardcoded&#39; and add an SPI for custom extensions.<br>
&gt; Your thoughts on this please.<br>
&gt;<br>
&gt; As before, I&#39;m happy to implement this myself, but I&#39;d like to discuss it first, so a future PR will be honored.<br>
&gt;<br>
&gt;<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>
&gt;<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>
<br>
<br>
_______________________________________________<br>
keycloak-dev mailing list<br>
<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
<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>