Hi i have a problem with a Server-side rest client that is supposed to call another server rest api. It's actually working in with JBoss AS 7.1 and Tomee, but the webservice respond with a 404 when i use Wildfly 10.1.
The target endpoint use cookie authentication to check authorization, this is done by a servletFilter. So to call the service i have a cookie: Cookie : "COOKIE_NAME:TOKEN"
The servlet filters are actually working fine, infact if i call the same webservice with any rest client (i tried Intellij's one and Postman) it's working fine.
The problem only happens from server side call done via a Play framework 1.2.5 application using play WS lib.
Here the code: (Superclass method return an instance of WS.WSRequest)
@play.mvc.Before(priority = 0)
protected static WS.WSRequest authCookieHttpClient(String relativeUrl) throws IllegalStateException {
if (JWT_AUDIENCE != null && JWT_ISSUER != null && JWT_SECRET != null && JWT_TIMEOUT != null && API_ENDPOINT != null && AUTH_COOKIE_NAME != null) {
JWTClaims jwtClaims = new JWTClaims(
JWT_ISSUER,
Security.getConnectedUser().username,
JWT_AUDIENCE,
JWT_TIMEOUT
);
WS.WSRequest request = WS.url(API_ENDPOINT + relativeUrl);
JWTProducer jwtProducer = new JWTProducer(JWT_SECRET, jwtClaims);
try {
request.setHeader("Cookie",
AUTH_COOKIE_NAME + "=" + URLEncoder.encode(jwtProducer.signPayload(), "utf-8"));
} catch (UnsupportedEncodingException e) {
Logger.error("Unable to encode cookie info", e);
}
return request;
}
throw new IllegalStateException("Cannot use parent controller: " + ApiSubscriber.class + " without configuring API endpoint and JWT features");
}
The calling code:
WS.HttpResponse res = authCookieHttpClient(areaUrl + sb.toString()).get();
The same request is working fine with Postman/Intellij Client (with the cookie header equal to the play WS request)
All is working fine with JBoss AS 7.1 (ee6) with JAX-RS impl. provided by Jersey
It's not working only with WildFly 10.1 (ee7) with JAX-RS impl provided by RestEasy. (redirects like was not auhtenticated by the cookie, so client return 404)
Any suggestion? Thanks.