# SHIELD: Can we use patterns while naming roles in roles.yml in SHIELD

**URL:** https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723
**Category:** Elasticsearch
**Tags:** elastic-stack-security
**Created:** [February 2, 2016, 12:29pm UTC](https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723 "2016-02-02T12:29:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![krushnat\_khawale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krushnat_khawale/32/6652_2.png) [@krushnat\_khawale](https://discuss.elastic.co/u/krushnat_khawale)
#### Post date: [February 2, 2016, 12:29pm UTC](https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723/1 "2016-02-02T12:29:40Z")

</div>

I am providing a functionality where I can create users with roles [admin, user]  
As there will be no of users going fall in both the categories and they will also be  
able to upload there files using logstash.  
**Specifying just admin and user roles in roles.yml file will let every admin access**  
**his own and every other admins 'index' similarly a user can also do the same.**

Is there way of using REGEX patterns for specifying roles like we do in index names?

---

<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: [February 2, 2016, 6:12pm UTC](https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723/2 "2016-02-02T18:12:22Z")

</div>

Hi,

If I understand correctly, I think the proper solution would be to create individual roles for the admins that administrate different indices using the pattern support in the names for indices.

For example in the roles.yml:

```auto
admin_a:
  indices:
    'a': all 

admin_b:
  indices:
    'b-*': all

```

Then the users would be assigned the appropriate roles. This would allow the administrators to be restricted to only the indices they need to administer.

---

<div class="post-metadata">

### Author: ![krushnat\_khawale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krushnat_khawale/32/6652_2.png) [@krushnat\_khawale](https://discuss.elastic.co/u/krushnat_khawale)
#### Post date: [February 4, 2016, 11:06am UTC](https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723/3 "2016-02-04T11:06:38Z")

</div>

Hi, Is there a utility to create roles? like esusers? or some workaround?  
If No what is the best way to programatically update apart from file parsing and update?  
Also is there a limitation on maximum no of roles and users per roles?

Regards, K

---

<div class="post-metadata">

### Author: ![krushnat\_khawale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krushnat_khawale/32/6652_2.png) [@krushnat\_khawale](https://discuss.elastic.co/u/krushnat_khawale)
#### Post date: [February 4, 2016, 11:08am UTC](https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723/4 "2016-02-04T11:08:10Z")

</div>

Also IS elasticsearch restart required after adding roles?

---

<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: [February 4, 2016, 11:24am UTC](https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723/5 "2016-02-04T11:24:38Z")

</div>

Currently, the way to do it is to make changes in the files; a automation tool will be helpful here in distributing the files to multiple instances. The users and roles files are watched for changes and will be reloaded during runtime if they have been changed, so there is no need for a restart. Does your use-case require you to create roles often?

In a future version of Shield, there will be APIs for user and role management.

---

<div class="post-metadata">

### Author: ![krushnat\_khawale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krushnat_khawale/32/6652_2.png) [@krushnat\_khawale](https://discuss.elastic.co/u/krushnat_khawale)
#### Post date: [February 4, 2016, 11:27am UTC](https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723/6 "2016-02-04T11:27:26Z")

</div>

Yes! We need to create roles very often. as per usecase we want each user to have secured access...  
Kindly guide?

Also appreciate the quick response!

---

<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: [February 4, 2016, 11:39am UTC](https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723/7 "2016-02-04T11:39:30Z")

</div>

Can you explain a bit more? Are you creating new users or new indices often that require new roles? If it is possible can you explain your workflow.

---

<div class="post-metadata">

### Author: ![krushnat\_khawale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krushnat_khawale/32/6652_2.png) [@krushnat\_khawale](https://discuss.elastic.co/u/krushnat_khawale)
#### Post date: [February 5, 2016, 2:46am UTC](https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723/8 "2016-02-05T02:46:22Z")

</div>

@jaymode Here is the workflow,

We are creating a system for uploading csv files quickly and to visualize data easily.  
Users who are going to use the system are employees with different designation like  
manager, team lead and developers.  
As a manager can add users in terms of manager, team lead and developers similarly  
a team lead can also add users like team lead and developers. we want to set access as follows,

Manager =\> should be able to view visualizations of self, team-leads he created and developers  
he created

Team-lead =\> should be able to do the same of self and developers he created

Developer =\> should be able to do the same of self only.

---

<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 6, 2017, 1:47pm UTC](https://discuss.elastic.co/t/shield-can-we-use-patterns-while-naming-roles-in-roles-yml-in-shield/40723/9 "2017-07-06T13:47:00Z")

</div>


