<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="">
Hi,
<div class=""><br class="">
</div>
<div class="">I have a rest endpoint running on wildfly 9.</div>
<div class=""><br class="">
</div>
<div class="">Wildfly and application is setup to use Keycloak and request to endpoints are intercepted with keycloak adapter. But is seems to be that it is not working. If auth header is not present keycloak just skips authentication and lets all request thru.
 It doesn’t matter do I use curl or browser.</div>
<div class=""><br class="">
</div>
<div class="">Wilfly logs says (last line comes from servlet filter)</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
2015-11-06 13:10:23,962 DEBUG [org.keycloak.adapters.PreAuthActionsHandler] (default task-17) adminRequest
<a href="https://localhost:8443/foobar/endpoint" class="">https://localhost:8443/foobar/endpoint</a></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
2015-11-06 13:10:23,969 TRACE [org.keycloak.adapters.RequestAuthenticator] (default task-17) --&gt; authenticate()</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
2015-11-06 13:10:23,969 TRACE [org.keycloak.adapters.RequestAuthenticator] (default task-17) try bearer</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
2015-11-06 13:10:23,969 DEBUG [org.keycloak.adapters.RequestAuthenticator] (default task-17) NOT_ATTEMPTED: bearer only</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
2015-11-06 13:10:23,970 DEBUG [org.keycloak.adapters.AuthenticatedActionsHandler] (default task-17) AuthenticatedActionsValve.invoke
<a href="https://localhost:8443/foobar/endpoint" class="">https://localhost:8443/foobar/endpoint</a></div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
2015-11-06 13:10:23,970 INFO&nbsp; [stdout] (default task-17) GET:/foobar/endpoint</div>
</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<br class="">
</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<br class="">
</div>
<div class="">If I add Authorization headar like this&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
Authorization: Bearer 123</div>
</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<br class="">
</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
I get HTTP/1.1 401 Unauthorized</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<br class="">
</div>
<div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">
<div style="margin: 0px; line-height: normal;" class="">WWW-Authenticate: Bearer realm=&quot;saas-pilot&quot;, error=&quot;invalid_token&quot;, error_description=&quot;Couldn't parse token”</div>
<div style="margin: 0px; line-height: normal;" class=""><br class="">
</div>
<div style="margin: 0px; line-height: normal;" class=""><br class="">
</div>
<div style="margin: 0px; line-height: normal;" class="">Is there something that I dont understand?</div>
<div style="margin: 0px; line-height: normal;" class=""><br class="">
</div>
<div style="margin: 0px; line-height: normal;" class="">I have tried with web.xml/keycloak.json and keycloak subsystem configuration methods, same outcome.</div>
<div style="margin: 0px; line-height: normal;" class=""><br class="">
</div>
<div style="margin: 0px; line-height: normal;" class="">Br,</div>
<div style="margin: 0px; line-height: normal;" class="">Tero</div>
<div style="margin: 0px; line-height: normal;" class=""><br class="">
</div>
<div style="margin: 0px; line-height: normal;" class=""><br class="">
</div>
<div style="margin: 0px; line-height: normal;" class=""><br class="">
</div>
</div>
</body>
</html>