Upgrading from Shield to X-Pack, FilterClient and authentication headers

Hi X-Pack Security users,

In Shield 2.4 I have a setup whereby my Client authenticates as a transport_client user, and the Authorization header is added to each request using a FilterClient.

I would like to carry this approach over to X-Pack, however the ActionRequest class no longer has a putHeader method. The documentation at https://www.elastic.co/guide/en/x-pack/current/java-clients.html claims that you can putHeader when the requests are built, but this method does not seem to exist.

I appreciate any help you can offer.
Best, Dan.

Hey Dan,

Sorry about that documentation error; we'll get that corrected. The way to do this in x-pack is:

PreBuiltXPackTransportClient = new PreBuiltXPackTransportClient(Settings.builder()....build());
String token = basicAuthHeaderValue("test_user", new SecuredString("changeme".toCharArray()));
SearchResponse response = client.filterWithHeader(Collections.singletonMap("Authorization", token)).prepareSearch().get();


Thanks. Your swift responses make up for any inaccuracies in the documentation. Thanks for your efforts!
Best, Dan.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.