# Caching in Elastic shield

**URL:** <https://discuss.elastic.co/t/caching-in-elastic-shield/72622>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [January 24, 2017, 11:33am UTC](https://discuss.elastic.co/t/caching-in-elastic-shield/72622 "2017-01-24T11:33:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gsb](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@gsb](https://discuss.elastic.co/u/gsb)\
**Post date:** [January 24, 2017, 11:33am UTC](https://discuss.elastic.co/t/caching-in-elastic-shield/72622/1 "2017-01-24T11:33:24Z")

</div>

Elastic shield documentation mentions that it can cache users for authentication However there's no clear explanation or an example on how to achieve this.

I have a native realm user and a file realm user (for file realm user I configured following)

shield:  
authc:  
realms:  
native\_name:  
type: native  
order: 0  
file\_name:  
type: file  
order: 1  
cache.ttl: 20m  
cache.max\_users: 100000

For Instance

When I make a rest call using rest client or curl

I would need to pass username/password with each request

curl -u filerealmusername:password -XGET'[http://localhost:9600/\_shield/user/username?pretty](http://localhost:9600/_shield/user/username?pretty)'

1 . How do I avoid passing username:password in subsequent requests ?

1. I'm trying to achieve this in elasticsearch python client , essentially I need to avoid passing username password in each request explicitly. For Instance following

es = Elasticsearch(  
['localhost',],  
http\_auth=('filerealmuser', 'secret'),  
port=9200,  
)

---

<div class="post-metadata">

**Author:** ![jaymode](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaymode/32/50103_2.png) [@jaymode](https://discuss.elastic.co/u/jaymode)\
**Post date:** [January 24, 2017, 12:08pm UTC](https://discuss.elastic.co/t/caching-in-elastic-shield/72622/2 "2017-01-24T12:08:42Z")

</div>

Currently, Shield and X-Pack only support basic authentication. The caching is an internal mechanism to improve performance but your requests still need to provide the username and password every time.

Tokens and/or sessions are something we are currently looking at but these will only be available in X-Pack.

---

<div class="post-metadata">

**Author:** ![gsb](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@gsb](https://discuss.elastic.co/u/gsb)\
**Post date:** [January 24, 2017, 12:33pm UTC](https://discuss.elastic.co/t/caching-in-elastic-shield/72622/3 "2017-01-24T12:33:46Z")

</div>

I see, I have integrated kibana through shield with elastic search and I have noticed that this requires username/password to be logged in once and maintained for session.

Kibana creates a session. May I know how is it able to achieve the same, as sessions are not supported in shield ?

Is there by any other means I can achieve a session like functionality in python ? For instance cookies or something similar ?

---

<div class="post-metadata">

**Author:** ![jaymode](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaymode/32/50103_2.png) [@jaymode](https://discuss.elastic.co/u/jaymode)\
**Post date:** [January 24, 2017, 12:54pm UTC](https://discuss.elastic.co/t/caching-in-elastic-shield/72622/4 "2017-01-24T12:54:35Z")

</div>

The session is at the Kibana layer only; Kibana still needs to pass the authentication credentials to elasticsearch.

---

<div class="post-metadata">

**Author:** ![gsb](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@gsb](https://discuss.elastic.co/u/gsb)\
**Post date:** [January 24, 2017, 1:22pm UTC](https://discuss.elastic.co/t/caching-in-elastic-shield/72622/5 "2017-01-24T13:22:18Z")

</div>

Does the official python client elasticsearch-py client facilitates similar capabilities for maintaining a session or cookies etc. ?

---

<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:** [February 21, 2017, 1:22pm UTC](https://discuss.elastic.co/t/caching-in-elastic-shield/72622/6 "2017-02-21T13:22:20Z")

</div>

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