0

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.

Yuri Blanc
  • 636
  • 10
  • 24

1 Answers1

0

The problem was caused by the queryString generated by the play framework java client. While on Jboss AS 7.1 with Jersey was working fine accepting a query like var1=&var2=123 with RestEasy this fails but no execeptions are thrown and it turns out to a 404 Response.

The target endpoint was of course mapping the queryString params using @QueryParam from javax.ws.rs.

I found the solution adding debug informations to WildFly standalone xml (for request/response) and then the exceptions where logged too.

log http requests in Wildfly

Hope it helps.

Yuri Blanc
  • 636
  • 10
  • 24