<div dir="ltr"><div>Hi Marc,<br><br></div><div>Thanks.<br></div><div>The plugin functionality for the roundtrip in our Proof of Concept setup is sufficient.<br></div><div>In the future I expect that we would need more flexibility in the mapping of access token properties onto headers.<br></div><div><br><div>Regards,<br><br></div><div>Ton<br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-10 12:12 GMT+01:00 Marc Savy <span dir="ltr">&lt;<a href="mailto:marc.savy@redhat.com" target="_blank">marc.savy@redhat.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sorry, missed out part of my sentence:<br>
<br>
If you feel the configuration options offered by the Keycloak OAuth2 policy *are insufficient* let me know,<br>
and we can work out what changes might be possible to help.<br>
<br>
On 10/12/2015 11:10, Marc Savy wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Nice! And understood - that should all work. If you feel the<br>
configuration options offered by the Keycloak OAuth2 policy let me know,<br>
and we can work out what changes might be possible to help.<br>
<br>
On 10/12/2015 11:06, Ton Swieb wrote:<br>
&gt; Yes we have set up Keycloak to delegate to a SAML IdP. So a user is<br>
&gt; redirected to a SAML IdP for login. After successfull login the user is<br>
&gt; automatically logged in in Keycloak and we can use the JS adapter to<br>
&gt; obtain an access token for accessing the Apiman gateway.<br>
&gt; We have this roundtrip working now, but we do still have some challenges<br>
&gt; with the mapping the SAML attributes to the Keycloak token.<br>
&gt;<br>
&gt;<br>
&gt; 2015-12-10 11:58 GMT+01:00 Marc Savy &lt;<a href="mailto:marc.savy@redhat.com" target="_blank">marc.savy@redhat.com</a><br>
&gt; &lt;mailto:<a href="mailto:marc.savy@redhat.com" target="_blank">marc.savy@redhat.com</a>&gt;&gt;:<br>
&gt;<br>
&gt;      Your JS snippet is indeed typical of what happens in the real world -<br>
&gt;      you generally wouldn&#39;t use a username and password in a plaintext<br>
&gt;      JS app - instead you would use a client secret that can easily be<br>
&gt;      regenerated (or login redirection for UI apps).<br>
&gt;<br>
&gt;      What you&#39;re doing is the typical work-flow in JS; Keycloak&#39;s JS library<br>
&gt;      does the work behind the scenes to do the heavy lifting for you.<br>
&gt;<br>
&gt;          Next step will be to test it with the SAML IdP instead of standalone<br>
&gt;            Keycloak, but I do not expect it to behave any differently.<br>
&gt;<br>
&gt;<br>
&gt;      You mean you are setting up Keycloak to delegate to your SAML IdP?<br>
&gt;<br>
&gt;      On 09/12/2015 16:02, Ton Swieb wrote:<br>
&gt;<br>
&gt;          Hi Marc,<br>
&gt;<br>
&gt;          I got it working, without the SAML IdP, using the Keycloak<br>
&gt;          Javascript<br>
&gt;          adapter.<br>
&gt;<br>
&gt;          I used the Keycloak JS-Console example and extended it with a<br>
&gt;          javascript<br>
&gt;          function that does a call the apiman-gateway after I have a<br>
&gt;          logged in<br>
&gt;          session with Keycloak.  Something like:<br>
&gt;                    var client = new XMLHttpRequest();<br>
&gt;                    client.open(&quot;GET&quot;, url, false);<br>
&gt;                    client.setRequestHeader(&quot;Accept&quot;, &quot;application/json&quot;);<br>
&gt;                    client.setRequestHeader(&quot;Authorization&quot;, &quot;Bearer &quot; +<br>
&gt;          keycloak.token);<br>
&gt;                    client.send();<br>
&gt;<br>
&gt;          The keycloak.token is available after a call to<br>
&gt;          keycloak.login(). Both<br>
&gt;          are part of the Keycloak javascript adapter.<br>
&gt;<br>
&gt;          Underneath the Javascript adapter still does a call similair to<br>
&gt;          <a href="http://127.0.0.1:8080/auth/realms/stottie/protocol/openid-connect/token" rel="noreferrer" target="_blank">http://127.0.0.1:8080/auth/realms/stottie/protocol/openid-connect/token</a><br>
&gt;          to retrieve the access token. With the difference that the<br>
&gt;          grant_type<br>
&gt;          used is authorization_code instead of password and a code is<br>
&gt;          supplied<br>
&gt;          instead of a username/password combination. I assume the code is<br>
&gt;          retrieved from the keycloak session. Not sure how it exactly<br>
&gt;          works, but<br>
&gt;          it works.<br>
&gt;<br>
&gt;          Next step will be to test it with the SAML IdP instead of standalone<br>
&gt;          Keycloak, but I do not expect it to behave any differently.<br>
&gt;<br>
&gt;          Regards,<br>
&gt;<br>
&gt;          Ton<br>
&gt;<br>
&gt;          2015-12-08 19:00 GMT+01:00 Ton Swieb &lt;<a href="mailto:ton@finalist.nl" target="_blank">ton@finalist.nl</a><br>
&gt;          &lt;mailto:<a href="mailto:ton@finalist.nl" target="_blank">ton@finalist.nl</a>&gt;<br>
&gt;          &lt;mailto:<a href="mailto:ton@finalist.nl" target="_blank">ton@finalist.nl</a> &lt;mailto:<a href="mailto:ton@finalist.nl" target="_blank">ton@finalist.nl</a>&gt;&gt;&gt;:<br>
&gt;<br>
&gt;               Hi Marc,<br>
&gt;<br>
&gt;               I am using the following setup:<br>
&gt;               1. Client -&gt; Keycloak (apiman realm) -&gt; SAML 2.0 IdP -&gt;<br>
&gt;          Keycloak<br>
&gt;               (apiman realm) -&gt; Client<br>
&gt;               2. Client -&gt; apiman gateway -&gt; Keycloak OAuth policy -&gt;<br>
&gt;          back-end -&gt;<br>
&gt;               apiman gateway -&gt; Client<br>
&gt;<br>
&gt;               The IdP is a SAML 2.0 IdP. I believe it is SimpleSAMLPHP.<br>
&gt;               It is unclear to me why it matters which IdP I am using,<br>
&gt;          because my<br>
&gt;               assumption is that:<br>
&gt;<br>
&gt;                 * I end up with a valid Keycloak session within the<br>
&gt;          apiman realm<br>
&gt;                 * the SAML 2.0 token should only be used by Keycloak to<br>
&gt;          issue a<br>
&gt;                   login session to the client.<br>
&gt;                 * the client itself will never directly use anyhting from<br>
&gt;          the SAML<br>
&gt;                   2.0 IdP, but should only use the stuff that Keycloak<br>
&gt;          mapped from<br>
&gt;                   the SAML token onto its own token.<br>
&gt;<br>
&gt;               I did ask the question on the keycloak mailinglist, but from a<br>
&gt;               different angle. I am afraid the solution for my problem<br>
&gt;          will be<br>
&gt;               somewhere in between.<br>
&gt;               Any help from your site is greatly appreciated :-)<br>
&gt;<br>
&gt;               Regards,<br>
&gt;<br>
&gt;               Ton<br>
&gt;<br>
&gt;<br>
&gt;               Message: 5<br>
&gt;               Date: Tue, 8 Dec 2015 16:58:26 +0000<br>
&gt;               From: Marc Savy &lt;<a href="mailto:marc.savy@redhat.com" target="_blank">marc.savy@redhat.com</a><br>
&gt;          &lt;mailto:<a href="mailto:marc.savy@redhat.com" target="_blank">marc.savy@redhat.com</a>&gt; &lt;mailto:<a href="mailto:marc.savy@redhat.com" target="_blank">marc.savy@redhat.com</a><br>
&gt;          &lt;mailto:<a href="mailto:marc.savy@redhat.com" target="_blank">marc.savy@redhat.com</a>&gt;&gt;&gt;<br>
&gt;               Subject: Re: [Apiman-user] Keycloak OAuth2 policy: Get<br>
&gt;          bearer token<br>
&gt;                        for logged in user without using username/password<br>
&gt;               To: <a href="mailto:apiman-user@lists.jboss.org" target="_blank">apiman-user@lists.jboss.org</a><br>
&gt;          &lt;mailto:<a href="mailto:apiman-user@lists.jboss.org" target="_blank">apiman-user@lists.jboss.org</a>&gt;<br>
&gt;          &lt;mailto:<a href="mailto:apiman-user@lists.jboss.org" target="_blank">apiman-user@lists.jboss.org</a><br>
&gt;          &lt;mailto:<a href="mailto:apiman-user@lists.jboss.org" target="_blank">apiman-user@lists.jboss.org</a>&gt;&gt;<br>
&gt;               Message-ID: &lt;<a href="mailto:56670C32.3060000@redhat.com" target="_blank">56670C32.3060000@redhat.com</a><br>
&gt;          &lt;mailto:<a href="mailto:56670C32.3060000@redhat.com" target="_blank">56670C32.3060000@redhat.com</a>&gt;<br>
&gt;               &lt;mailto:<a href="mailto:56670C32.3060000@redhat.com" target="_blank">56670C32.3060000@redhat.com</a><br>
&gt;          &lt;mailto:<a href="mailto:56670C32.3060000@redhat.com" target="_blank">56670C32.3060000@redhat.com</a>&gt;&gt;&gt;<br>
&gt;               Content-Type: text/plain; charset=UTF-8; format=flowed<br>
&gt;<br>
&gt;               To expand on that - depending on exactly what type of IdP (and<br>
&gt;               specifically which technology) you were delegating to, it<br>
&gt;          may be<br>
&gt;               possible to do what you&#39;re asking - or you may need to write<br>
&gt;               something custom.<br>
&gt;<br>
&gt;               Can you provide more detail?<br>
&gt;<br>
&gt;               Also, if you have very specific Keycloak questions you<br>
&gt;          might be best<br>
&gt;               served on the keycloak-user mailing list, which is<br>
&gt;          extremely active<br>
&gt;               (<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a>).<br>
&gt;<br>
&gt;               On 08/12/2015 16:53, Marc Savy wrote:<br>
&gt;                &gt; Hi Ton,<br>
&gt;                &gt;<br>
&gt;                &gt; I&#39;m not quite sure what you mean, but I think what<br>
&gt;          you&#39;re asking<br>
&gt;               for is<br>
&gt;                &gt; brokerage/delegation in the form:<br>
&gt;                &gt;<br>
&gt;                &gt; 1. Client &lt;-&gt; Keycloak &lt;-&gt; Other IdP.<br>
&gt;                &gt; 2. Client &lt;-&gt; apiman gateway<br>
&gt;                &gt;<br>
&gt;                &gt; Regards,<br>
&gt;                &gt; Marc<br>
&gt;                &gt;<br>
&gt;                &gt; On 08/12/2015 15:28, Ton Swieb wrote:<br>
&gt;                &gt; &gt; Hi,<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt; I would like to secure my api&#39;s using the Keycloak<br>
&gt;          OAuth2 policy.<br>
&gt;                &gt; &gt; Similair to what is described in the blog post of Marc<br>
&gt;          Savy:<br>
&gt;                &gt; &gt;<br>
&gt;          <a href="http://www.apiman.io/blog/gateway/security/oauth2/keycloak/authentication/authorization/2015/06/09/keycloak-oauth2.html" rel="noreferrer" target="_blank">http://www.apiman.io/blog/gateway/security/oauth2/keycloak/authentication/authorization/2015/06/09/keycloak-oauth2.html</a><br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt; Only with the difference that Keycloak delegates the<br>
&gt;          login to a<br>
&gt;               third<br>
&gt;                &gt; &gt; party IdP. After logging in at this third party IdP I<br>
&gt;          end up<br>
&gt;               with an<br>
&gt;                &gt; &gt; active session in the Apiman UI (the apiman realm of<br>
&gt;          Keycloak).<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt; Now I am wondering how to get the bearer token,<br>
&gt;          because I do<br>
&gt;               not have a<br>
&gt;                &gt; &gt; username/password combination I can use to make a call<br>
&gt;          like:<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt; |curl -X POST<br>
&gt;                &gt; &gt;<br>
&gt;          <a href="http://127.0.0.1:8080/auth/realms/stottie/protocol/openid-connect/token" rel="noreferrer" target="_blank">http://127.0.0.1:8080/auth/realms/stottie/protocol/openid-connect/token</a><br>
&gt;                &gt; &gt; -H &quot;Content-Type: application/x-www-form-urlencoded&quot; -d<br>
&gt;                &gt; &gt; &quot;username=rincewind&quot; -d &#39;password=apiman&#39; -d<br>
&gt;               &#39;grant_type=password&#39; -d<br>
&gt;                &gt; &gt; &#39;client_id=apiman&#39;|<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt; Because the username/password combination is linked to the<br>
&gt;               third party<br>
&gt;                &gt; &gt; IdP and not to Keycloak itself.<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt; Is there another way to obtain the bearer token?<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt; Perhaps this is aquestion which I should address at<br>
&gt;          the keycloak<br>
&gt;                &gt; &gt; mailinglist. I will try to ask the question there as well.<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt; Regards,<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt; Ton<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt;<br>
&gt;                &gt; &gt; _______________________________________________<br>
&gt;                &gt; &gt; Apiman-user mailing list<br>
&gt;                &gt; &gt; <a href="mailto:Apiman-user@lists.jboss.org" target="_blank">Apiman-user@lists.jboss.org</a><br>
&gt;          &lt;mailto:<a href="mailto:Apiman-user@lists.jboss.org" target="_blank">Apiman-user@lists.jboss.org</a>&gt;<br>
&gt;          &lt;mailto:<a href="mailto:Apiman-user@lists.jboss.org" target="_blank">Apiman-user@lists.jboss.org</a><br>
&gt;          &lt;mailto:<a href="mailto:Apiman-user@lists.jboss.org" target="_blank">Apiman-user@lists.jboss.org</a>&gt;&gt;<br>
&gt;                &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/apiman-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/apiman-user</a><br>
&gt;                &gt; &gt;<br>
&gt;                &gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
_______________________________________________<br>
Apiman-user mailing list<br>
<a href="mailto:Apiman-user@lists.jboss.org" target="_blank">Apiman-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/apiman-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/apiman-user</a><br>
<br>
</blockquote>
<br>
</blockquote></div><br></div>