arimoham
(Mohamed Arif Hanifa)
August 15, 2017, 5:12am
1
I'm trying to implement basic authentication on elasticsearch using RestFilter as given in below post's:
Hi,
I am trying to write simple custom authentication plugin for elasticsearch v5.4.1. In previous versions before 5.4.2, it could be done with Restfilters. But now they are not present. Somewhere i read that use RestHandlers for the same. However , I am not able to get code executed inside my custom handler.
What i am trying to achieve is that i will get a header having authentication information in my rest request. Will validate that information using external services inside my custom handl…
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
s1monw
(Simon Willnauer)
August 18, 2017, 10:17am
2
when you plugin implements ActionPlugin
you can override getRestHandlerWrapper
that wrapps every rest handler before executing this should help.
1 Like
arimoham
(Mohamed Arif Hanifa)
August 18, 2017, 2:36pm
3
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,
Thanks for the reply. I was able to create a basic plugin for the same in the following way..
My plugin class:
public class ESPlugin extends Plugin implements ActionPlugin {
public List<RestHandler> getRestHandlers(Settings settings, RestController restController,
ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter,
IndexNameExpressionResolver indexNameExpressionResolver, Supplier<DiscoveryNodes> nodesInCluster) {
return Arrays.asList(n…
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.
s1monw
(Simon Willnauer)
August 18, 2017, 2:43pm
4
true, we have a new API as I explained above you can wrap every handler and do your authentication there.
arimoham
(Mohamed Arif Hanifa)
August 18, 2017, 2:55pm
5
if you dont mind, can you please explain with a sudo code for basic authentication. It will really help me, please.
system
(system)
Closed
September 15, 2017, 2:55pm
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.