<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I created a small demo app to show you what I meant:</div><div class=""><a href="https://github.com/gerbermichi/keycloak/tree/master/examples/demo-template/rest-resources" class="">https://github.com/gerbermichi/keycloak/tree/master/examples/demo-template/rest-resources</a></div><div class=""><br class=""></div><div class="">As you can see, keycloak consumes the post data during the authentication step, which is wrong, because the resource should be public (without any authentication)</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>curl -X POST -H „Content-Type: text/plain" <a href="http://localhost:8080/rest-resources/public" class="">http://localhost:8080/rest-resources/public</a> -d 'hello world'</div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>You said:</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><div style="font-family: Helvetica; font-size: 12px;" class="">My previous bug fix for this problem was wrong, but I think my latests changes in the RequestAuthenticator class would solve this problem.</div><div style="font-family: Helvetica; font-size: 12px;" class="">You can find all my changes here:&nbsp;<a href="https://github.com/gerbermichi/keycloak/commit/512a68c5fa405567fe56968b5fdd9bb51eeb3316" class="">https://github.com/gerbermichi/keycloak/commit/512a68c5fa405567fe56968b5fdd9bb51eeb3316</a></div><div style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></div><div class=""><div style="font-family: Helvetica; font-size: 12px;" class=""><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>curl -X POST -H „Content-Type: text/plain" <a href="http://localhost:8080/rest-resources/public" class="">http://localhost:8080/rest-resources/public</a> -d 'hello world'</div></div><div style="margin: 0px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>You said: hello world</div></div></div><div class=""><br class=""></div><div class="">The only question is, how to implement the&nbsp;</div><div class=""><font face="Menlo" style="font-size: 11px;" class="">protected&nbsp;abstract&nbsp;boolean&nbsp;isAuthenticationRequired();</font></div><div class="">method correctly in the&nbsp;JettyRequestAuthenticator and&nbsp;CatalinaRequestAuthenticator class.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">Am 19.12.2014 um 17:03 schrieb Michael Gerber &lt;<a href="mailto:gerbermichi@me.com" class="">gerbermichi@me.com</a>&gt;:</div><br class="Apple-interchange-newline"><div class=""><div class=""><div class="">Hi all,</div><div class=""><br class=""></div><div class="">I created today a build from the latest master branch and struggled with the following problem.</div><div class="">I've got some REST services which are excluded from keycloak, so I can access them without a logged in user. (see detail from web.xml)</div><div class=""><span style="line-height: 1.5;" class="">The request body in these post rest services were always empty. I found out that my wildfly tried to authenticate all requests.</span></div><div class=""><span style="line-height: 1.5;" class="">The&nbsp;</span>tokenStore.saveRequest() method in the OAuthRequestAuthenticator class read the inputStream and so it was empty later on.</div><div class=""><br class=""></div><div class="">I dont understand why all my requests are authenticated, even when they are excluded through the web.xml file.</div><div class="">So, I added the following lines in the ServletKeycloakAuthMech class in the authenticate method: (see&nbsp;<a href="https://github.com/gerbermichi/keycloak/commit/1eaafcd3d9ad4082429ab500a4512c87d47ed75c" class="">https://github.com/gerbermichi/keycloak/commit/1eaafcd3d9ad4082429ab500a4512c87d47ed75c</a>)</div><div class=""><div class="">if (!deployment.isConfigured() || !securityContext.isAuthenticationRequired()) {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return AuthenticationMechanismOutcome.NOT_ATTEMPTED;</div><div class="">}</div></div><div class=""><br class=""></div><div class="">This hack solved all my problems. Is this a bug and should i create a pull request? Or are there some problems in my project configuration?</div><div class=""><br class=""></div><div class="">Detail from my web.xml file:</div><div class=""><div class="">&nbsp; &lt;security-constraint&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;web-resource-collection&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;web-resource-name&gt;Client WS&lt;/web-resource-name&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;url-pattern&gt;/clientws/*&lt;/url-pattern&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/web-resource-collection&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;web-resource-collection&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;web-resource-name&gt;Client Exchange WS&lt;/web-resource-name&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;url-pattern&gt;/services/exchange/*&lt;/url-pattern&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/web-resource-collection&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;user-data-constraint&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;transport-guarantee&gt;CONFIDENTIAL&lt;/transport-guarantee&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/user-data-constraint&gt;</div><div class="">&nbsp; &nbsp; &lt;/security-constraint&gt;</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &lt;security-constraint&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;web-resource-collection&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;web-resource-name&gt;All&lt;/web-resource-name&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;url-pattern&gt;/*&lt;/url-pattern&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/web-resource-collection&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;auth-constraint&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;role-name&gt;myRole&lt;/role-name&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/auth-constraint&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;user-data-constraint&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;transport-guarantee&gt;CONFIDENTIAL&lt;/transport-guarantee&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/user-data-constraint&gt;</div><div class="">&nbsp; &nbsp; &lt;/security-constraint&gt;</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &lt;login-config&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;auth-method&gt;KEYCLOAK&lt;/auth-method&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;realm-name&gt;myRealm&lt;/realm-name&gt;</div><div class="">&nbsp; &nbsp; &lt;/login-config&gt;</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &lt;security-role&gt;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &lt;role-name&gt;myRole&lt;/role-name&gt;</div><div class="">&nbsp; &nbsp; &lt;/security-role&gt;</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div>_______________________________________________<br class="">keycloak-dev mailing list<br class=""><a href="mailto:keycloak-dev@lists.jboss.org" class="">keycloak-dev@lists.jboss.org</a><br class="">https://lists.jboss.org/mailman/listinfo/keycloak-dev</div></blockquote></div><br class=""></body></html>