# Custom Plugin add filter to search query by external access policies

**URL:** https://discuss.elastic.co/t/custom-plugin-add-filter-to-search-query-by-external-access-policies/285723
**Category:** Elasticsearch
**Created:** [October 2, 2021, 3:08am UTC](https://discuss.elastic.co/t/custom-plugin-add-filter-to-search-query-by-external-access-policies/285723 "2021-10-02T03:08:39Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![David\_Sheard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_sheard/32/81142_2.png) [@David\_Sheard](https://discuss.elastic.co/u/David_Sheard)
#### Post date: [October 2, 2021, 3:08am UTC](https://discuss.elastic.co/t/custom-plugin-add-filter-to-search-query-by-external-access-policies/285723/1 "2021-10-02T03:08:39Z")

</div>

Hi,  
I'm wanting to create a custom plugin. The purpose is to make a rest call to an external service to apply access control polices to search requests. Is there any sample code or an article that would assist?  
Appreciated

---

<div class="post-metadata">

### Author: ![David\_Sheard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_sheard/32/81142_2.png) [@David\_Sheard](https://discuss.elastic.co/u/David_Sheard)
#### Post date: [October 7, 2021, 2:45am UTC](https://discuss.elastic.co/t/custom-plugin-add-filter-to-search-query-by-external-access-policies/285723/2 "2021-10-07T02:45:17Z")

</div>

Hi,  
I tried the example authorization engine in the examples. However unless I mis-understood it's functionality it doesn't seem to work. I can load the plugin. However being added to the role makes no difference to may access? Any further information regarding this example?

---

<div class="post-metadata">

### Author: ![David\_Sheard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_sheard/32/81142_2.png) [@David\_Sheard](https://discuss.elastic.co/u/David_Sheard)
#### Post date: [October 7, 2021, 2:46am UTC](https://discuss.elastic.co/t/custom-plugin-add-filter-to-search-query-by-external-access-policies/285723/3 "2021-10-07T02:46:24Z")

</div>

Just to clarify I'm refering to "security-authorization-engine" example

---

<div class="post-metadata">

### Author: ![David\_Sheard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_sheard/32/81142_2.png) [@David\_Sheard](https://discuss.elastic.co/u/David_Sheard)
#### Post date: [October 8, 2021, 5:20am UTC](https://discuss.elastic.co/t/custom-plugin-add-filter-to-search-query-by-external-access-policies/285723/4 "2021-10-08T05:20:52Z")

</div>

> [@David\_Sheard](#):
>
> security-authorization-engine

Hi,  
So I got the security-authorization-engine example working with the test cases passing. However when I load into Elasticsearch it seems to make no difference ☹  
I also converted it to a Maven project and set up as below. Am a missing something in the structure?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/c/4c5e7e438917a50b90121b0a05d5506c6ae20414.png)

---

<div class="post-metadata">

### Author: ![David\_Sheard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_sheard/32/81142_2.png) [@David\_Sheard](https://discuss.elastic.co/u/David_Sheard)
#### Post date: [October 9, 2021, 12:11am UTC](https://discuss.elastic.co/t/custom-plugin-add-filter-to-search-query-by-external-access-policies/285723/5 "2021-10-09T00:11:31Z")

</div>

Hi,  
Still no help from anyone ☹  
As mentioned all test cases work but when I deploy it doesn't work. I've deployed the rescore plugin with no issues. Do I need to add anything to my yml file?  
It deploys. Using against 7.15.0. I'm also using native realm, is that an issue? Wouldn't have thought so.

---

<div class="post-metadata">

### Author: ![David\_Sheard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_sheard/32/81142_2.png) [@David\_Sheard](https://discuss.elastic.co/u/David_Sheard)
#### Post date: [October 9, 2021, 12:24am UTC](https://discuss.elastic.co/t/custom-plugin-add-filter-to-search-query-by-external-access-policies/285723/6 "2021-10-09T00:24:46Z")

</div>

Hi,  
Finally worked out the solution. If anyone wants the answer let me know!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 6, 2021, 12:25am UTC](https://discuss.elastic.co/t/custom-plugin-add-filter-to-search-query-by-external-access-policies/285723/7 "2021-11-06T00:25:27Z")

</div>

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