<div dir="ltr"><div><div class="gmail_quote"><div dir="ltr"><pre style="color:rgb(0,0,0)"><div>Hi Bill,</div><div>I see you have pushed some changes.</div><div>Tell me as soon as you need me to test it.</div><div><br></div><div>Thank you,</div><div>Davide.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Weird... I&#39;m actually screwing around with writing a security proxy <br>right now.  I just started like an hour or so ago so I&#39;m not exactly <br>sure...but I don&#39;t think you can implement this with the current <br>codebase.  You need a Undertow only (no servlet) authentication <br>mechanism and to set up the security handler chain correctly.  (See the <br>BasicAuthServer example in Undertow).
I should have something working in master by the end of the week.
On 11/19/2014 6:33 PM, Davide Ungari wrote:<br>&gt;<i> Hi everybody,
</i>&gt;<i> this is the big picture:
</i>&gt;<i> a. frontend application with Undertow
</i>&gt;<i> b. backend application with Undertow and Resteasy for REST API
</i>&gt;<br>&gt;<i> Both are using Keycloak as SSO.
</i>&gt;<br>&gt;<i> I&#39;m trying to configure a proxy from A to B in order to expose backend
</i>&gt;<i> API without CORS problems to the frontend.
</i>&gt;<br>&gt;<i> I asked support also to Undertow guys but the issue seems around the
</i>&gt;<i> integration of Keycloack in Undertow. My proxy is implemented like:
</i>&gt;<br>&gt;<i>                  final ProxyClient proxyClient = new
</i>&gt;<i> SimpleProxyClientProvider(new URI(&quot;<a href="http://localhost:8181/" target="_blank">http://localhost:8181</a>
</i>&gt;<i> &lt;<a href="http://localhost:8181/" target="_blank">http://localhost:8181/</a>&gt;&quot;));
</i>&gt;<i>                  final ProxyHandler proxyHandler = new
</i>&gt;<i> ProxyHandler(proxyClient, servletHandler);
</i>&gt;<i>                  proxyHandler.addRequestHeader(new
</i>&gt;<i> HttpString(&quot;Authorization&quot;), new ExchangeAttribute() {
</i>&gt;<i>                      @Override
</i>&gt;<i>                      public String readAttribute(HttpServerExchange
</i>&gt;<i> exchange) {
</i>&gt;<i>                          exchange.
</i>&gt;<i>                          RefreshableKeycloakSecurityContext context =
</i>&gt;<i> (RefreshableKeycloakSecurityContext) exchange.getSecurityContext();
</i>&gt;<i>                          return &quot;Bearer &quot; + context.getTokenString();
</i>&gt;<i>                      }
</i>&gt;<br>&gt;<i>                      @Override
</i>&gt;<i>                      public void writeAttribute(HttpServerExchange
</i>&gt;<i> exchange, String newValue) throws ReadOnlyAttributeException {
</i>&gt;<i>                          // TODO Auto-generated method stub
</i>&gt;<i>                      }
</i>&gt;<i>                  });
</i>&gt;<br>&gt;<i> The problem is that the exchange.getSecurityContext() is always null.
</i>&gt;<i> Any ideas?
</i>&gt;<br>&gt;<i> Thanks
</i>&gt;<br>&gt;<br>&gt;<br>&gt;<i> --
</i>&gt;<i> Davide
</i>&gt;<br>&gt;<br>&gt;<i> _______________________________________________
</i>&gt;<i> keycloak-user mailing list
</i>&gt;<i> <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">keycloak-user at lists.jboss.org</a>
</i>&gt;<i> <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a>
</i>&gt;
-- <span class=""><font color="#888888"><br>Bill Burke<br>JBoss, a division of Red Hat<br><a href="http://bill.burkecentral.com/" target="_blank">http://bill.burkecentral.com</a></font></span></blockquote></pre></div></div></div></div>