# Issue securing Elastic Search and Kibana

**URL:** https://discuss.elastic.co/t/issue-securing-elastic-search-and-kibana/192730
**Category:** Elasticsearch
**Tags:** elastic-stack-security
**Created:** [July 29, 2019, 2:50pm UTC](https://discuss.elastic.co/t/issue-securing-elastic-search-and-kibana/192730 "2019-07-29T14:50:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![elasuser](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@elasuser](https://discuss.elastic.co/u/elasuser)
#### Post date: [July 29, 2019, 2:50pm UTC](https://discuss.elastic.co/t/issue-securing-elastic-search-and-kibana/192730/1 "2019-07-29T14:50:35Z")

</div>

Hello,  
I'm new to elastic search and having some issues with securing it together with Kibana security. This is what I've done:  
1- Secure elasticsearch in the yaml with file realm

```
     xpack.security.enabled: true
     #File realm
     xpack:
     security:
       authc:
         realms:
           file:
             file1:
               order: 0

```

2- Create new user with role using the command line

```
  client_user:

  run_as: ['']

  cluster: ['monitor']

  indices:

       - names: ['events-*']
         privileges: ['read']
         field_security:
         grant: ['category', '@timestamp', 'message']
         query: '{"match": {"category": "click"}}'
  
       - names: ['logstash-*']
             privileges:
        - view_index_metadata
        - read
	
         - names: ['.kibana*'] 
            privileges:
                  - manage
                  - read
                  - index

```

3- In our application code, I added basic authentication to use the ElasticClient  
4- Allow user to login in Kibana by adding security in kibana.yml

Now whenever I run the application, the NEST response i always empty. However without enabling security I always get the response for all previous indexes.  
I'm stuck with this. Any help is highly appreciated!

---

<div class="post-metadata">

### Author: ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)
#### Post date: [July 29, 2019, 9:48pm UTC](https://discuss.elastic.co/t/issue-securing-elastic-search-and-kibana/192730/2 "2019-07-29T21:48:50Z")

</div>

Please don't post unformatted code, logs, or configuration as it's very hard to read.

Instead, paste the text and format it with \</\> icon or pairs of triple backticks (```), and check the preview window to make sure it's properly formatted before posting it. This makes it more likely that your question will receive a useful answer.

It would be great if you could update your post to solve this.

---

<div class="post-metadata">

### Author: ![elasuser](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@elasuser](https://discuss.elastic.co/u/elasuser)
#### Post date: [July 31, 2019, 7:09pm UTC](https://discuss.elastic.co/t/issue-securing-elastic-search-and-kibana/192730/3 "2019-07-31T19:09:36Z")

</div>

Basically What I'm trying to do is:

**1-** _Secure Elastic Search with username and password credentials_  
**2-** _Add basic authentication on ElasticClient in my applications to use these credentials_  
**3-** _Make Kibana users login with username/password to visualize._

After that I need to still get response from a search(just like before securing it)

Any working advise is very welcomed! Thank you!

---

<div class="post-metadata">

### Author: ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)
#### Post date: [August 1, 2019, 10:02am UTC](https://discuss.elastic.co/t/issue-securing-elastic-search-and-kibana/192730/4 "2019-08-01T10:02:14Z")

</div>

I would urge you to read through the documentation. Start with [https://www.elastic.co/guide/en/elastic-stack-overview/current/elasticsearch-security.html](https://www.elastic.co/guide/en/elastic-stack-overview/current/elasticsearch-security.html) that describes everything and then maybe follow the Getting Started guide at [https://www.elastic.co/guide/en/elastic-stack-overview/current/security-getting-started.html](https://www.elastic.co/guide/en/elastic-stack-overview/current/security-getting-started.html)

---

<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: [August 29, 2019, 10:02am UTC](https://discuss.elastic.co/t/issue-securing-elastic-search-and-kibana/192730/5 "2019-08-29T10:02:15Z")

</div>

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