<div dir="ltr">Hi Stephen,<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> Instead of requiring all of that preconfiguration data for each API to point the plugin to a specific keycloak realm, it dynamically makes a call to Keycloak in real-time to get and cache the token&#39;s realm&#39;s public key so that the oauth token can be validated.<br></blockquote><div><br></div><div>Thanks for describing this. When we created the KC policy this functionality wasn&#39;t yet available on their side. I think it would be a fantastic addition to the community plugin, so I&#39;ve pencilled it in.</div><div><br></div><div>Some policies could definitely use some feature expansion and general (re)polishing; this will be a focus in the near future.</div><div><br></div><div>I suspect the CLI tooling and/or generated headless functionality might interest you, also? I&#39;ll be sure to solicit your feedback once that goes live.<br></div><div><br></div><div>Regards,</div><div>Marc</div><div><br></div><div>On Tuesday, November 14, 2017, Stephen Henrie &lt;<a href="mailto:stephen@saasindustries.com" target="_blank">stephen@saasindustries.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div>Hi Marc,<br><br></div>Yes and no. We decided to go a different route and not use the contracts and plans, since we don&#39;t want to have to dole out apikeys. We are just using the &quot;public&quot; API functionality at this point. <br><br>However, in order to minimize the configuration needed for each new API entry, I went ahead and created a custom policy plugin which combines some parts of the keycloak oauth plugin and the authorization plugin. Instead of requiring all of that preconfiguration data for each API to point the plugin to a specific keycloak realm, it dynamically makes a call to Keycloak in real-time to get and cache the token&#39;s realm&#39;s public key so that the oauth token can be validated.<br><br></div>Thanks for checking in though.<br><br></div>Stephen <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 13, 2017 at 12:37 PM, Marc Savy <span dir="ltr">&lt;<a>marc.savy@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hey Stephen,<br>
<br>
Any progress on this? Did you manage to solve your issue?<br>
<br>
Regards,<br>
Marc<br>
<br>
On 10 August 2017 at 10:33, Marc Savy &lt;<a>marc.savy@redhat.com</a>&gt; wrote:<br>
&gt; Is your setup roughly:<br>
&gt;<br>
&gt; ClientApp -&gt; Plan [Keycloak] -&gt; API [Authz]<br>
&gt;<br>
&gt; Which version of Keycloak are you using?<br>
&gt; What type of roles are you using? For example, realm.<br>
&gt;<br>
&gt; The way Keycloak roles are modelled has changed fairly significantly<br>
&gt; over the last few versions of KC. We might not be handling that<br>
&gt; correctly anymore.<br>
&gt;<br>
&gt; On 8 August 2017 at 11:08, Marc Savy &lt;<a>marc.savy@redhat.com</a>&gt; wrote:<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; If I understand your description correctly, this should work. And in<br>
&gt;&gt; my quick tests, it seems to work.  I might not be replicating<br>
&gt;&gt; your setup perfectly though.<br>
&gt;&gt;<br>
&gt;&gt; For example let&#39;s imagine we have a setup such that:<br>
&gt;&gt;<br>
&gt;&gt; Client Policies [] // None<br>
&gt;&gt; Plan Policies [Foo, Bar]<br>
&gt;&gt; API Policies [Baz]<br>
&gt;&gt;<br>
&gt;&gt; This ultimately flattens to a policy chain of:<br>
&gt;&gt;<br>
&gt;&gt; Caller &lt;-&gt; [ Foo &lt;-&gt; Bar &lt;-&gt; Baz ] &lt;-&gt; API<br>
&gt;&gt;<br>
&gt;&gt; So if your setup is (N of):<br>
&gt;&gt;<br>
&gt;&gt; Plan [ Keycloak Auth ]<br>
&gt;&gt; API [ Authz ]<br>
&gt;&gt;<br>
&gt;&gt; This should always result in: Keycloak *then* Authz, passing roles as<br>
&gt;&gt; defined in config.<br>
&gt;&gt;<br>
&gt;&gt; If that isn&#39;t happening then there&#39;s a bug. I may may need to collect<br>
&gt;&gt; some more information from you to see whether I can replicate the<br>
&gt;&gt; issue.<br>
&gt;&gt;<br>
&gt;&gt; Regards,<br>
&gt;&gt; Marc<br>
&gt;&gt;<br>
&gt;&gt; On 5 August 2017 at 01:21, Stephen Henrie &lt;<a>stephen@saasindustries.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; My goal is minimize the amount of Apiman configuration that I need to do by<br>
&gt;&gt;&gt; sharing a single, common authentication Plan using the Keycloak plugin<br>
&gt;&gt;&gt; across all APIs while using an API specific authorization policy for each<br>
&gt;&gt;&gt; individual API.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; As such,  I am trying to configure a single, global plan within Apiman that<br>
&gt;&gt;&gt; can be used for ensuring authentication policy using the Keycloak plugin<br>
&gt;&gt;&gt; which forwards all of my realm roles. This single plan would be assigned to<br>
&gt;&gt;&gt; all of my APIs in the Org, which would allow me to only have to configure<br>
&gt;&gt;&gt; the Keycloak realm information in one place. Then for each individual API, I<br>
&gt;&gt;&gt; was hoping to add a single Authorization policy plugin configured with<br>
&gt;&gt;&gt; endpoints and paths specific for each API.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Something like<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Api1 ---&gt; Keycloak Plan Abc<br>
&gt;&gt;&gt;   +----&gt;Authorization Policy (123)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Api2 ---&gt; Keycloak Plan Abc<br>
&gt;&gt;&gt;   +----&gt;Authorization Policy (456)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; When I do this and call one of the API endpoints, I am getting the following<br>
&gt;&gt;&gt; error:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; curl -k  -H &quot;Authorization: Bearer $T&quot;<br>
&gt;&gt;&gt; <a href="https://localhost:9443/apiman-gateway/chassi/chassi-tenant-bff/1.0/mytenants" rel="noreferrer" target="_blank">https://localhost:9443/apiman-<wbr>gateway/chassi/chassi-tenant-b<wbr>ff/1.0/mytenants</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; {&quot;type&quot;:&quot;Other&quot;,&quot;failureCode&quot;:<wbr>10010,&quot;responseCode&quot;:0,&quot;messag<wbr>e&quot;:&quot;No roles<br>
&gt;&gt;&gt; have been extracted during authentication.  Make sure the authorization<br>
&gt;&gt;&gt; policy comes *after* a compatible authentication policy in your<br>
&gt;&gt;&gt; configuration.&quot;,&quot;headers&quot;:[]}<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; It would seem that the Keycloak plugin that is configured in the Plan<br>
&gt;&gt;&gt; assigned to the API is not forwarding the realm roles to the Authentication<br>
&gt;&gt;&gt; policy which is also assigned to the same API.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Is this by design? Do the authentication and authorization policies have to<br>
&gt;&gt;&gt; be within the same entity (ie. Plan, Api, etc) and not passed out of a plan<br>
&gt;&gt;&gt; to be used by downstream policies?  If so, is there another way to configure<br>
&gt;&gt;&gt; plans and policies that will allow me to accomplish my goal?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Thanks in advance!<br>
&gt;&gt;&gt; Stephen<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt; Apiman-user mailing list<br>
&gt;&gt;&gt; <a>Apiman-user@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/apiman-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailma<wbr>n/listinfo/apiman-user</a><br>
&gt;&gt;&gt;<br>
</blockquote></div><br></div>
</blockquote></div>
</div>