<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.E-mailStijl18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=NL link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Stian, I can see your point. Using the realm name as the root level certainly has advantages. It also really fixes everything to a realm, but I guess that is what you want. So how about the current ‘/admin’ url, how does that fit in the new picture? Because that would be my next best target to hook into. Furthermore, there’s currently a ‘/version’ root path that should end up somewhere else. Personally, I think it’s not so bad to have a descriptive root level like ‘realms’, which leaves open the possibility to add extra root level paths, like meta data (version) or special contexts (admin, customPath).<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>Van:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Stian Thorgersen [mailto:sthorger@redhat.com] <br><b>Verzonden:</b> dinsdag 8 december 2015 10:32<br><b>Aan:</b> Greg Jones <gregj@thesoftwarecottage.com.au><br><b>CC:</b> Erik Mulder <erik.mulder@docdatapayments.com>; keycloak-dev@lists.jboss.org<br><b>Onderwerp:</b> Re: [keycloak-dev] Add custom REST paths? New SPI?<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>-1 To adding rest endpoints to the root level. I'd like to get rid of 'realms' 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'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 'realms' part.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On 8 December 2015 at 10:22, Greg Jones <<a href="mailto:gregj@thesoftwarecottage.com.au" target="_blank">gregj@thesoftwarecottage.com.au</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><p class=MsoNormal>+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><span style='color:#888888'>Greg Jones</span></span><o:p></o:p></p><div><div><p class=MsoNormal><br><br>> On 8 Dec 2015, at 8:17 PM, Erik Mulder <<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>> wrote:<br>><br>> Pedro's change (see below) is kindof what I was looking for, but for my case and for general flexibility I think it's good to also have a more basic point to hook into the REST API's.<br>> 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>><br>> So are the Keycloak dev's open to a PR with a new SPI that enables you to add custom REST paths?<br>> For example, you could create something like:<br>> <a href="http://localhost:8080/auth/myPath/myResource" target="_blank">http://localhost:8080/auth/myPath/myResource</a><br>><br>><br>> -----Oorspronkelijk bericht-----<br>> Van: Pedro Igor Silva [mailto:<a href="mailto:psilva@redhat.com">psilva@redhat.com</a>]<br>> Verzonden: maandag 7 december 2015 22:18<br>> Aan: Erik Mulder <<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>><br>> Onderwerp: Re: [keycloak-dev] Add custom REST paths? New SPI?<br>><br>> It is part of a working in progress around fine-grained authorization [1].<br>><br>> The new SPI changes [2] specific to Keycloak are located in a specific branch [3] in my Keycloak fork.<br>><br>> 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>><br>> [1] <a href="https://github.com/pedroigor/keycloak-authz" target="_blank">https://github.com/pedroigor/keycloak-authz</a><br>> [2] <a href="https://github.com/pedroigor/keycloak/commit/5e99614aacb70f7840a5ae25cfeaf3fc9d74ac54" target="_blank">https://github.com/pedroigor/keycloak/commit/5e99614aacb70f7840a5ae25cfeaf3fc9d74ac54</a><br>> [3] <a href="https://github.com/pedroigor/keycloak/tree/keycloak-authz-modified" target="_blank">https://github.com/pedroigor/keycloak/tree/keycloak-authz-modified</a><br>><br>> Regards.<br>><br>> ----- Original Message -----<br>> From: "Erik Mulder" <<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>><br>> To: "Pedro Igor Silva" <<a href="mailto:psilva@redhat.com">psilva@redhat.com</a>><br>> Sent: Monday, December 7, 2015 5:51:26 PM<br>> Subject: RE: [keycloak-dev] Add custom REST paths? New SPI?<br>><br>> Great, that's probably all we need!<br>> I'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>> Can you point me to / provide me with these changes so I can give it a spin? Thanks!<br>><br>> ________________________________________<br>> Van: Pedro Igor Silva [<a href="mailto:psilva@redhat.com">psilva@redhat.com</a>]<br>> Verzonden: maandag 7 december 2015 16:03<br>> Aan: Erik Mulder<br>> CC: <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>> Onderwerp: Re: [keycloak-dev] Add custom REST paths? New SPI?<br>><br>> I've done something at this regard, where you can use a SPI in order to plug additional APIs for:<br>><br>> * Realm Admin RESTFul API (eg.: used by admin console)<br>> * Realm RESFTFul API (eg.: to plug additional endpoints for realms)<br>><br>> The two Provider interfaces are very simple and just provide a single method:<br>><br>> Object getResource(String pathName);<br>><br>> Where pathName is the path that must be resolved to your custom JAX-RS resource.<br>><br>> The factories are also very simple and allows you to build those resources for the current Realm and KeycloakSession. Eg.:<br>><br>> RealmResourceProvider create(RealmModel realm, KeycloakSession keycloakSession);<br>><br>> Do you need something other than that ?<br>><br>> Regards.<br>> Pedro Igor<br>><br>> ----- Original Message -----<br>> From: "Erik Mulder" <<a href="mailto:erik.mulder@docdatapayments.com">erik.mulder@docdatapayments.com</a>><br>> To: <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>> Sent: Monday, December 7, 2015 12:46:39 PM<br>> Subject: [keycloak-dev] Add custom REST paths? New SPI?<br>><br>> 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>> So far we'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>> I know I've promised some PR's for this and they will come, but first we'd like to get everything fully working, so we know it's a well functioning whole.<br>><br>> The last piece of the puzzle is extending the REST services to include CRUD actions for our custom resources. I'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's constructor and that's that. No way to extend or to 'interfere' there.<br>><br>> So my question is: is there any 'official' way to add extra REST paths to Keycloak?<br>><br>> 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>><br>> singletons.add(new ServerVersionResource());<br>> singletons.add(new RealmsResource());<br>> singletons.add(new AdminRoot());<br>><br>> So just plain contructor calls. That seems like an easy target for 'SPI-ing' :-).<br>> Or just leave the current ones 'hardcoded' and add an SPI for custom extensions.<br>> Your thoughts on this please.<br>><br>> As before, I'm happy to implement this myself, but I'd like to discuss it first, so a future PR will be honored.<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" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a><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" 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" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a><o:p></o:p></p></div></div></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>