I can't find any good sample or doc that explains this clearly. I can successfully authenticate with the (older) RestTemplate:
HttpClientBuilder httpClient = HttpClients.custom();
BasicCredentialsProvider provider = new BasicCredentialsProvider();
Credentials cred = new NTCredentials("my-user", "my-password", null, "my-domain");
provider.setCredentials(AuthScope.ANY, cred);
httpClient.setDefaultCredentialsProvider(provider);
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.httpClient = httpClient.build();
RestTemplate restTemplate = new RestTemplate(request);
restTemplate.getForEntity("https://my.url.com", String.class)
I haven't been able to find a way to pass NTCredentials
(or Credentials
) to WebClient, have tried
WebClient client = WebClient.builder()
.filter(ExchangeFilterFunctions.basicAuthentication("user", "password"))
.build();
also
WebClient client = WebClient.builder().build();
client.get().headers(h -> h.setBasicAuth("user", "password"))...
But neither approach worked with WebClient
Questions:
- How do you do Windows/NTLM authentication with Spring WebClient?
- Is there anyway I can get NTLM or Windows auth working without supplying user/password when running in Windows using currrent user context?