1

I'm trying to setup up an http client to authenticate with spnego (apache http client 4.5.2)

Here's the code that setups the client

    System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");

    final CredentialsProvider credsProvider = new SystemDefaultCredentialsProvider();
    credsProvider.setCredentials(new AuthScope(null, -1, null), new KerberosCredentials(null));

    final HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setDefaultCredentialsProvider(credsProvider);
    final ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(builder.build());
    final Client client = new ResteasyClientBuilder().httpEngine(engine).build();

On the server, I have a JAX-RS service which is sitting behind a waffle.servlet.NegotiateSecurityFilter to allow for ntlm or spnego authentication.

When I send my HTTP request from my chrome rest client, it works, authentication is successfully completed using negotiate.

When I try and use the apache http client however, it fails with the message in the log:

    2018-03-05 16:47:16,048 DEBUG o.a.h.impl.auth.GGSSchemeBase main Authentication already attempted   
    2018-03-05 16:47:16,048 DEBUG o.a.h.i.auth.HttpAuthenticator main Authentication failed   

After some further investigation I've discovered that the waffle filter is encoutingering GSS_S_CONTINUE_NEEDED and responding with an additional challenge which the apache client is simply ignoring and giving up on.

I've tested my apache client setup against another service which uses spnego (provided by a 3rd party) and it works properly, although doesn't employ the continue token.

I'm not sure if my system is setup incorrectly, and that the continue token shouldn't be happeneing or if the apache http client is improperly configured (or doesn't support continue tokens at all)

There's a very old ticket here https://issues.apache.org/jira/browse/HTTPCLIENT-1107 indicating that something was added to handle additional challenges, but from reading the code in org.apache.http.impl.auth.GGSSchemeBase.parseChallenge(CharArrayBuffer, int, int) it looks as though only the first challange is ever accepted.

Martin Cassidy
  • 686
  • 1
  • 9
  • 28

0 Answers0