<p dir="ltr">There&#39;s two issues here really:</p>
<p dir="ltr">#1 KeycloakSession bound to a realm. Pretty much all requests with the exception to admin can take the realm from KeycloakContext. I&#39;d like to extend that so realm can always be returned from KeycloakContext, which I think we will get to when we redo master realm stuff</p>
<p dir="ltr">#2 Shorten/clean-up urls. Resources could in fact be realm specific. There could be different cache settings, or even different images etc for each realm. The fact that it&#39;s not ATM is more a limitation than anything. Version doesn&#39;t matter if it&#39;s avail under a realm or not really.</p>
<p dir="ltr">I reckon dropping realms wouldn&#39;t just shorten the url, but also make things cleaner and simpler.</p>
<div class="gmail_quote">On 9 Dec 2015 6:16 pm, &quot;Marek Posolda&quot; &lt;<a href="mailto:mposolda@redhat.com">mposolda@redhat.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+1<br>
<br>
some things like ServerVersionResource or static resources ( keycloak.js<br>
etc) are just not tight to any specific realm. Removing &quot;/realms&quot; would<br>
mean that we will need to move all of them under the path specific to<br>
some realm. For example move keycloak.js under<br>
&quot;<a href="http://localhost:8080/auth/foo/keycloak.js" rel="noreferrer" target="_blank">http://localhost:8080/auth/foo/keycloak.js</a>&quot; . But that doesn&#39;t seem to<br>
be very good practice as keycloak.js is not resource specific to realm<br>
&quot;foo&quot; .<br>
<br>
If we want shorter and more user-memorable URLs, we can maybe introduce<br>
some URLAliasService, where will people have possibility to define short<br>
URL aliases for some endpoints. This might have support for regexes etc.<br>
However Apache HTTPD already provides something like this AFAIK<br>
<br>
Marek<br>
<br>
<br>
On 09/12/15 15:33, Bill Burke wrote:<br>
&gt; Once we go to host/{realms} we are stuck with it.  The matching rules of<br>
&gt; JAX-RS will prevent us from adding any top level resource that is more<br>
&gt; specific.  Stian, we might want to reconsider removing &quot;/realms&quot;.<br>
&gt;<br>
&gt; On 12/8/2015 5:34 AM, Stian Thorgersen wrote:<br>
&gt;&gt; &#39;admin&#39; will probably move at some point to be under the realm.<br>
&gt;&gt;<br>
&gt;&gt; &#39;version&#39; would move as well. Although this one should probably be<br>
&gt;&gt; removed altogether.<br>
&gt;&gt;<br>
&gt;&gt; KeycloakSession and SPIs needs to be tied to a specific realm. This<br>
&gt;&gt; makes everything cleaner.<br>
&gt;&gt;<br>
&gt;&gt; Besides it just doesn&#39;t make any sense to add arbitrary rest endpoints<br>
&gt;&gt; to Keycloak. A rest endpoint should be tied to a realm, otherwise it<br>
&gt;&gt; just doesn&#39;t make sense to host it on the Keycloak server.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On 8 December 2015 at 11:18, Erik Mulder<br>
&gt;&gt; &lt;<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a><br>
&gt;&gt; &lt;mailto:<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>&gt;&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;      Stian, I can see your point. Using the realm name as the root level<br>
&gt;&gt;      certainly has advantages. It also really fixes everything to a<br>
&gt;&gt;      realm, but I guess that is what you want. So how about the current<br>
&gt;&gt;      ‘/admin’ url, how does that fit in the new picture? Because that<br>
&gt;&gt;      would be my next best target to hook into. Furthermore, there’s<br>
&gt;&gt;      currently a ‘/version’ root path that should end up somewhere else.<br>
&gt;&gt;      Personally, I think it’s not so bad to have a descriptive root level<br>
&gt;&gt;      like ‘realms’, which leaves open the possibility to add extra root<br>
&gt;&gt;      level paths, like meta data (version) or special contexts (admin,<br>
&gt;&gt;      customPath).____<br>
&gt;&gt;<br>
&gt;&gt;      __ __<br>
&gt;&gt;<br>
&gt;&gt;      __ __<br>
&gt;&gt;<br>
&gt;&gt;      *Van:*Stian Thorgersen [mailto:<a href="mailto:sthorger@redhat.com">sthorger@redhat.com</a><br>
&gt;&gt;      &lt;mailto:<a href="mailto:sthorger@redhat.com">sthorger@redhat.com</a>&gt;]<br>
&gt;&gt;      *Verzonden:* dinsdag 8 december 2015 10:32<br>
&gt;&gt;      *Aan:* Greg Jones &lt;<a href="mailto:gregj@thesoftwarecottage.com.au">gregj@thesoftwarecottage.com.au</a><br>
&gt;&gt;      &lt;mailto:<a href="mailto:gregj@thesoftwarecottage.com.au">gregj@thesoftwarecottage.com.au</a>&gt;&gt;<br>
&gt;&gt;      *CC:* Erik Mulder &lt;<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a><br>
&gt;&gt;      &lt;mailto:<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>&gt;&gt;;<br>
&gt;&gt;      <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;      *Onderwerp:* Re: [keycloak-dev] Add custom REST paths? New SPI?____<br>
&gt;&gt;<br>
&gt;&gt;      __ __<br>
&gt;&gt;<br>
&gt;&gt;      -1 To adding rest endpoints to the root level. I&#39;d like to get rid<br>
&gt;&gt;      of &#39;realms&#39; part as some point and have all rest endpoints sit<br>
&gt;&gt;      underneath a realm. This makes sure the KeycloakSession always knows<br>
&gt;&gt;      what realm is being handled, so we don&#39;t need to pass the realm<br>
&gt;&gt;      around as it can be retrived from the KeycloakContext. It also means<br>
&gt;&gt;      that the url can be shortened as we can drop the &#39;realms&#39; part.____<br>
&gt;&gt;<br>
&gt;&gt;      __ __<br>
&gt;&gt;<br>
&gt;&gt;      On 8 December 2015 at 10:22, Greg Jones<br>
&gt;&gt;      &lt;<a href="mailto:gregj@thesoftwarecottage.com.au">gregj@thesoftwarecottage.com.au</a><br>
&gt;&gt;      &lt;mailto:<a href="mailto:gregj@thesoftwarecottage.com.au">gregj@thesoftwarecottage.com.au</a>&gt;&gt; wrote:____<br>
&gt;&gt;<br>
&gt;&gt;          +1 for these changes. We have been looking at a way to add<br>
&gt;&gt;          custom REST endpoints and would be happy to use this approach.<br>
&gt;&gt;<br>
&gt;&gt;          Regards<br>
&gt;&gt;          Greg Jones____<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;           &gt; On 8 Dec 2015, at 8:17 PM, Erik Mulder<br>
&gt;&gt;          &lt;<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a><br>
&gt;&gt;          &lt;mailto:<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>&gt;&gt; wrote:<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; Pedro&#39;s change (see below) is kindof what I was looking for,<br>
&gt;&gt;          but for my case and for general flexibility I think it&#39;s good to<br>
&gt;&gt;          also have a more basic point to hook into the REST API&#39;s.<br>
&gt;&gt;           &gt; I implemented and tested my own suggestion of having an SPI<br>
&gt;&gt;          to be able to add a REST resource at the root level. Combined<br>
&gt;&gt;          with the (coming) ability to freely extend the JPA entities and<br>
&gt;&gt;          DB schema, I think this creates a really powerful extensibility<br>
&gt;&gt;          to Keycloak. When we finish these changes, I can write a blog<br>
&gt;&gt;          post about what we did, why and how as a showcase for custom<br>
&gt;&gt;          extensions to Keycloak.<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; So are the Keycloak dev&#39;s open to a PR with a new SPI that<br>
&gt;&gt;          enables you to add custom REST paths?<br>
&gt;&gt;           &gt; For example, you could create something like:<br>
&gt;&gt;           &gt; <a href="http://localhost:8080/auth/myPath/myResource" rel="noreferrer" target="_blank">http://localhost:8080/auth/myPath/myResource</a><br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; -----Oorspronkelijk bericht-----<br>
&gt;&gt;           &gt; Van: Pedro Igor Silva [mailto:<a href="mailto:psilva@redhat.com">psilva@redhat.com</a><br>
&gt;&gt;          &lt;mailto:<a href="mailto:psilva@redhat.com">psilva@redhat.com</a>&gt;]<br>
&gt;&gt;           &gt; Verzonden: maandag 7 december 2015 22:18<br>
&gt;&gt;           &gt; Aan: Erik Mulder &lt;<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a><br>
&gt;&gt;          &lt;mailto:<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>&gt;&gt;<br>
&gt;&gt;           &gt; Onderwerp: Re: [keycloak-dev] Add custom REST paths? New SPI?<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; It is part of a working in progress around fine-grained<br>
&gt;&gt;          authorization [1].<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; The new SPI changes [2] specific to Keycloak are located in a<br>
&gt;&gt;          specific branch [3] in my Keycloak fork.<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; I need to discuss these changes with Bill and see what he<br>
&gt;&gt;          thinks about it. Depending on his feedback, I can prepare a PR<br>
&gt;&gt;          and send these changes to upstream.<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; [1] <a href="https://github.com/pedroigor/keycloak-authz" rel="noreferrer" target="_blank">https://github.com/pedroigor/keycloak-authz</a><br>
&gt;&gt;           &gt; [2]<br>
&gt;&gt;          <a href="https://github.com/pedroigor/keycloak/commit/5e99614aacb70f7840a5ae25cfeaf3fc9d74ac54" rel="noreferrer" target="_blank">https://github.com/pedroigor/keycloak/commit/5e99614aacb70f7840a5ae25cfeaf3fc9d74ac54</a><br>
&gt;&gt;           &gt; [3]<br>
&gt;&gt;          <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;&gt;           &gt;<br>
&gt;&gt;           &gt; Regards.<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; ----- Original Message -----<br>
&gt;&gt;           &gt; From: &quot;Erik Mulder&quot; &lt;<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a><br>
&gt;&gt;          &lt;mailto:<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>&gt;&gt;<br>
&gt;&gt;           &gt; To: &quot;Pedro Igor Silva&quot; &lt;<a href="mailto:psilva@redhat.com">psilva@redhat.com</a><br>
&gt;&gt;          &lt;mailto:<a href="mailto:psilva@redhat.com">psilva@redhat.com</a>&gt;&gt;<br>
&gt;&gt;           &gt; Sent: Monday, December 7, 2015 5:51:26 PM<br>
&gt;&gt;           &gt; Subject: RE: [keycloak-dev] Add custom REST paths? New SPI?<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; Great, that&#39;s probably all we need!<br>
&gt;&gt;           &gt; I&#39;d like to try it out, but I cannot find any reference to<br>
&gt;&gt;          what you mention on Github. Is it (going to be) a pull request?<br>
&gt;&gt;          Is it going to be part of a future release?<br>
&gt;&gt;           &gt; Can you point me to / provide me with these changes so I can<br>
&gt;&gt;          give it a spin? Thanks!<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; ________________________________________<br>
&gt;&gt;           &gt; Van: Pedro Igor Silva [<a href="mailto:psilva@redhat.com">psilva@redhat.com</a><br>
&gt;&gt;          &lt;mailto:<a href="mailto:psilva@redhat.com">psilva@redhat.com</a>&gt;]<br>
&gt;&gt;           &gt; Verzonden: maandag 7 december 2015 16:03<br>
&gt;&gt;           &gt; Aan: Erik Mulder<br>
&gt;&gt;           &gt; CC: <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt;&gt;          &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;<br>
&gt;&gt;           &gt; Onderwerp: Re: [keycloak-dev] Add custom REST paths? New SPI?<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; I&#39;ve done something at this regard, where you can use a SPI<br>
&gt;&gt;          in order to plug additional APIs for:<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt;    * Realm Admin RESTFul API (eg.: used by admin console)<br>
&gt;&gt;           &gt;    * Realm RESFTFul API (eg.: to plug additional endpoints<br>
&gt;&gt;          for realms)<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; The two Provider interfaces are very simple and just provide<br>
&gt;&gt;          a single method:<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt;    Object getResource(String pathName);<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; Where pathName is the path that must be resolved to your<br>
&gt;&gt;          custom JAX-RS resource.<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; The factories are also very simple and allows you to build<br>
&gt;&gt;          those resources for the current Realm and KeycloakSession. Eg.:<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; RealmResourceProvider create(RealmModel realm,<br>
&gt;&gt;          KeycloakSession keycloakSession);<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; Do you need something other than that ?<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; Regards.<br>
&gt;&gt;           &gt; Pedro Igor<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; ----- Original Message -----<br>
&gt;&gt;           &gt; From: &quot;Erik Mulder&quot; &lt;<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a><br>
&gt;&gt;          &lt;mailto:<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>&gt;&gt;<br>
&gt;&gt;           &gt; To: <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt;&gt;          &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;<br>
&gt;&gt;           &gt; Sent: Monday, December 7, 2015 12:46:39 PM<br>
&gt;&gt;           &gt; Subject: [keycloak-dev] Add custom REST paths? New SPI?<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; As some of you might know, our team is busy adding data to<br>
&gt;&gt;          the keycloak system to incorporate some custom authorization<br>
&gt;&gt;          information in the access token.<br>
&gt;&gt;           &gt; So far we&#39;ve successfully extended the JPA entities,<br>
&gt;&gt;          Liquibase table definitions and added a custom mapper to put<br>
&gt;&gt;          that data in the access token. All of this without custom<br>
&gt;&gt;          modifications to the original keycloak sources. This is working<br>
&gt;&gt;          great, thanks for the support so far!<br>
&gt;&gt;           &gt; I know I&#39;ve promised some PR&#39;s for this and they will come,<br>
&gt;&gt;          but first we&#39;d like to get everything fully working, so we know<br>
&gt;&gt;          it&#39;s a well functioning whole.<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; The last piece of the puzzle is extending the REST services<br>
&gt;&gt;          to include CRUD actions for our custom resources. I&#39;ve been<br>
&gt;&gt;          looking into the way RESTEasy/JAX-RS works and it seems to me<br>
&gt;&gt;          that in the current implementation there is no way to add extra<br>
&gt;&gt;          paths. As I see it now, the KeycloakApplication class will<br>
&gt;&gt;          register some singletons in it&#39;s constructor and that&#39;s that. No<br>
&gt;&gt;          way to extend or to &#39;interfere&#39; there.<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; So my question is: is there any &#39;official&#39; way to add extra<br>
&gt;&gt;          REST paths to Keycloak?<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; If not, is it an idea to add this as a new SPI? The current<br>
&gt;&gt;          code for adding root paths in the KeycloakApplication<br>
&gt;&gt;          constructor lists:<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt;        singletons.add(new ServerVersionResource());<br>
&gt;&gt;           &gt;        singletons.add(new RealmsResource());<br>
&gt;&gt;           &gt;        singletons.add(new AdminRoot());<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; So just plain contructor calls. That seems like an easy<br>
&gt;&gt;          target for &#39;SPI-ing&#39; :-).<br>
&gt;&gt;           &gt; Or just leave the current ones &#39;hardcoded&#39; and add an SPI for<br>
&gt;&gt;          custom extensions.<br>
&gt;&gt;           &gt; Your thoughts on this please.<br>
&gt;&gt;           &gt;<br>
&gt;&gt;           &gt; As before, I&#39;m happy to implement this myself, but I&#39;d like<br>
&gt;&gt;          to discuss it first, so a future PR will be honored.<br>
&gt;&gt;           &gt;<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;          &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;<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;&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;          &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;<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;&gt;<br>
&gt;&gt;<br>
&gt;&gt;          _______________________________________________<br>
&gt;&gt;          keycloak-dev mailing list<br>
&gt;&gt;          <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a>&gt;<br>
&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;&gt;<br>
&gt;&gt;      __ __<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; keycloak-dev mailing list<br>
&gt;&gt; <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&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;&gt;<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>
</blockquote></div>