# Inject a term filter for basic security

**URL:** <https://discuss.elastic.co/t/inject-a-term-filter-for-basic-security/26810>\
**Category:** Elasticsearch\
**Created:** [August 4, 2015, 2:59pm UTC](https://discuss.elastic.co/t/inject-a-term-filter-for-basic-security/26810 "2015-08-04T14:59:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristan0x](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tristan0x/32/4019_2.png) [@tristan0x](https://discuss.elastic.co/u/tristan0x)\
**Post date:** [August 4, 2015, 2:59pm UTC](https://discuss.elastic.co/t/inject-a-term-filter-for-basic-security/26810/1 "2015-08-04T14:59:57Z")

</div>

Hello,

I am using Kibana 4 and Elasticsearch 1.7 to search across logs of several users. I want those users to only see their documents, based on a "user" field set of each document.

Kibana is proxied by a Python Flask application doing, among others things, authentication. The proxy provides Kibana the authenticated user name thru HTTP headers.

I currently have an Elasticsearch plugin catching this HTTP header, and an ActionFilter that registers the filter as string (for example: "term user john.doe") in the SearchRequest context. But then I am stuck. I don't find a suitable module to tweak the query afterward.

Do you have any clue how to achieve this?  
I still have a workaround, by putting a proxy in front of Elasticsearch to inject the filter in the \_search and \_msearch API methods, but that would not be very elegant.

I saw it was possible to register post-filters in 1.6, it seems both not supported and not efficient because run during aggregation.

Best regards

---

<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:** [July 5, 2017, 11:57pm UTC](https://discuss.elastic.co/t/inject-a-term-filter-for-basic-security/26810/2 "2017-07-05T23:57:30Z")

</div>

Closed on July 5, 2017, 11:57pm UTC


