Basic Authentication using RestFilter

I'm trying to implement basic authentication on elasticsearch using RestFilter as given in below post's:

and

https://qbox.io/blog/secure-elasticsearch-authentication-plugin-tutorial

Looks like from version greater than 5.1.2, RestFilter can not be registered to RestHandler, as the RestFilter class itself removed from org.elasticsearch.rest package.

Can somebody please let me know how to achieve basic authentication using RestFilter or RestHandler to add it as plugin to Elasticsearch?

According to @chanchal in post - Using RestHandlers for custom Authentication Plugin, he is able to create his custom AuthenticationFilter by extending RestFilter in ES version 5.4.2 - not sure how he is able to do that when RestFilter is removed from org.elasticsearch.rest package.

Any help on his would greatly appreciated, please.

thanks

when you plugin implements ActionPlugin you can override getRestHandlerWrapper that wrapps every rest handler before executing this should help.

1 Like

Thanks for your reply @s1monw.

My main concern is - RestController api doesn't support 'registerFilter' method anymore as shown below

@Inject
public AuthenticationHandler(Settings settings, RestController controller) {
super(settings);
controller.registerFilter(new AuthenticationFilter());
}

And also, RestFilter class is also removed from elasticsearch API, so I cant extend this class and create a custom filter class as shown below,

public class AuthenticationFilter extends RestFilter {
}

I'm trying to follow the example given in below post,

but because of above mentioned two clarifications, not sure how to proceed, please.

Could you please explain with an example or sudo code - I'm new to elasticsearch.

Many thanks in advance.

true, we have a new API as I explained above you can wrap every handler and do your authentication there.

if you dont mind, can you please explain with a sudo code for basic authentication. It will really help me, please.

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