Hi,
I'm building a custom plugin and need to retrieve, at some point, all info about a specific role by its name.
How can I do that?
Do I need to use org.elasticsearch.client.Client, is so could you provide a sample please?
Thanks
Regards
Hi,
I'm building a custom plugin and need to retrieve, at some point, all info about a specific role by its name.
How can I do that?
Do I need to use org.elasticsearch.client.Client, is so could you provide a sample please?
Thanks
Regards
Without more information about what type of plugin you have, and where you want to retrieve the roles, it's hard to provide a useful sample.
If you have a Client, then you can construct an instance of org.elasticsearch.xpack.core.security.client.SecurityClient and call getRoles from that.
Hi,
thank you for you answer.
It's a plugin built upon the one from this guide.
The only Elasticsearch dependencies I have are:
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elastic.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>x-pack-core</artifactId>
<version>${elastic.version}</version>
<scope>provided</scope>
</dependency>
and when I'm in the buildRole() method in WebstoreRolesProvider class I want to retrieve information from the Set<String> names of roles coming from the lookup() method.
I saw the org.elasticsearch.xpack.core.security.client.SecurityClient, but I'm not sure how to build an ElasticsearchClient implementation and pass it to its constructor.
Do I need to add any specific dependency?
Thanks
edit:
I also saw that the future will be using RestHighLevelClient so is there any way to use it to retrieve roles info?
Thanks
Client implements ElasticsearchClient, so it you have a Client then you can construct a SecurityClient.
You need to get the Client as part of the Plugin.createComponents method, and then retain a reference to that client for use in your Realm.
in
WebstoreRolesProviderclass I want to retrieve information from theSet<String> namesof roles coming from thelookup()method.
That doesn't mean sense to me. Your roles provider needs to create those roles - they will not exist in Elasticsearch. If they did exist in Elasticsearch then your roles provider would not be called.
thanks @TimV I'll try that!
That doesn't mean sense to me. Your roles provider needs to create those roles - they will not exist in Elasticsearch. If they did exist in Elasticsearch then your roles provider would not be called.
oh I see. I'll review my logic then. Thanks
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.