# Vault OIDC with google, how to restrict roles to specific groups

**URL:** <https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976>\
**Category:** Vault\
**Created:** [October 1, 2020, 5:39pm UTC](https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976 "2020-10-01T17:39:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![night-gold](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/night-gold/32/12302_2.png) [@night-gold](https://discuss.hashicorp.com/u/night-gold)\
**Post date:** [October 1, 2020, 5:39pm UTC](https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976/1 "2020-10-01T17:39:24Z")

</div>

I installed a vault and configured OIDC with gsuite, that was already an adventure in itself as the documentation is limited and even wrong at more than one place.

Finally I have a working authentication with my google accounts and I began to create roles, and there I saw a huge issue. How do you restrict google users from using a role. Let’s say I create a gsuite-admin role that has access to all of vault administration, any user entering the role before login can assume it.

I tried to use the different claims but those seems to be only for vault created groups or other things.

Does anyone has a solution for that?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![Romashk0](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/romashk0/32/12563_2.png) [@Romashk0](https://discuss.hashicorp.com/u/Romashk0)\
**Post date:** [October 8, 2020, 2:33pm UTC](https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976/2 "2020-10-08T14:33:02Z")

</div>

I am also interested in this question!

---

<div class="post-metadata">

**Author:** ![alexsandro225](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/alexsandro225/32/12580_2.png) [@alexsandro225](https://discuss.hashicorp.com/u/alexsandro225)\
**Post date:** [October 8, 2020, 6:31pm UTC](https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976/3 "2020-10-08T18:31:37Z")

</div>

I’m also interested in this question.

---

<div class="post-metadata">

**Author:** ![mgchahad](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mgchahad/32/12582_2.png) [@mgchahad](https://discuss.hashicorp.com/u/mgchahad)\
**Post date:** [October 8, 2020, 6:36pm UTC](https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976/4 "2020-10-08T18:36:44Z")

</div>

Yeap! I wish to know how to apply these permissions using OIDC (GSuite).

---

<div class="post-metadata">

**Author:** ![austingebauer](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/austingebauer/32/33080_2.png) [@austingebauer](https://discuss.hashicorp.com/u/austingebauer)\
**Post date:** [October 8, 2020, 10:33pm UTC](https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976/5 "2020-10-08T22:33:06Z")

</div>

Hello, @night-gold. I’m happy to help answer your questions. Please let me know which parts of the documentation you’ve found to be incorrect.

From what I’ve gathered, you’d like to prevent specific Google users from logging in with a specific role. Can you help to clarify a bit more as to how you’re trying to use G Suite groups?

One way I can think of to accomplish the behavior would be to specify [bound\_claims](https://www.vaultproject.io/docs/auth/jwt#bound-claims) on the role. `bound_claims` can be used to check arbitrary claims and prevent a successful login if claims values don’t match expected values. Have you tried to use `bound_claims` to achieve the behavior you want?

---

<div class="post-metadata">

**Author:** ![night-gold](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/night-gold/32/12302_2.png) [@night-gold](https://discuss.hashicorp.com/u/night-gold)\
**Post date:** [October 9, 2020, 8:28am UTC](https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976/6 "2020-10-09T08:28:54Z")

</div>

Hello,

The documentation I used is that one: [vault oidc provider](https://www.vaultproject.io/docs/auth/jwt_oidc_providers.html)

For the unclear part in the documentation what was the most unclear was where to put the gsuite\_service\_account, I had to try multiple things until I figured out in a cluster mode you need to have the file deployed on each instances. I think the description should be “Path on all vault instances…”.

Then the example configuration and role does not work… I tried really hard to give the conf in the command line after having issues with the UI… and it was impossible to give the provider\_config as in the example… An UI example may be best for this part… Same on the role example, claims could not be declared that way, I had to declare a json file and then call it with “@filename” to be able to declare claims.

I tried to use bound\_claims, but when I do that even if I’m part of the group I declare in the role, I can’t get to login, it just gives an error, I tried something like that:  
{  
“allowed\_redirect\_uris”: “[https://URL/ui/vault/auth/oidc/oidc/callback,http://localhost:8250/oidc/callback](https://URL/ui/vault/auth/oidc/oidc/callback,http://localhost:8250/oidc/callback)”,  
“user\_claim”: “sub”,  
“policies”: “vault\_admin”,  
“ttl”: “24h”,  
“groups\_claim”: “devops”,  
“oidc\_scopes”: “profile”,  
“bound\_claims”: {  
“group”: [“devops”]  
}  
}

So I tried that but then nobody is able to connect… We check in the Gsuite console and I’m in the group, if I remove the claim I can connect but anyone can connect using the role.

What is the right way to use the roles and Gsuite groups to limit the role?

---

<div class="post-metadata">

**Author:** ![austingebauer](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/austingebauer/32/33080_2.png) [@austingebauer](https://discuss.hashicorp.com/u/austingebauer)\
**Post date:** [October 19, 2020, 11:14pm UTC](https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976/7 "2020-10-19T23:14:47Z")

</div>

Thanks for the feedback, @night-gold. I’ll be updating the documentation to make it clear that the service account JSON file needs to be available on each instance.

Are you able to provide an example of what didn’t work for declaring both the config and role? The examples documented at [https://www.vaultproject.io/docs/auth/jwt\_oidc\_providers.html#configuration](https://www.vaultproject.io/docs/auth/jwt_oidc_providers.html#configuration) work for me using the Vault CLI without any issue.

In the meantime, I’m having a closer look at what we can do to allow `bound_claims` to be used to limit the role usage to a particular G Suite group when logging in.

---

<div class="post-metadata">

**Author:** ![night-gold](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/night-gold/32/12302_2.png) [@night-gold](https://discuss.hashicorp.com/u/night-gold)\
**Post date:** [October 20, 2020, 7:39am UTC](https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976/8 "2020-10-20T07:39:58Z")

</div>

Hello @austingebauer , thanks for you answer.

The error was really specific to fields that contains multiple values… It was not being recognize as a map, like in this [issue](https://github.com/hashicorp/vault-plugin-auth-jwt/issues/68) when following the doc.

---

<div class="post-metadata">

**Author:** ![austingebauer](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/austingebauer/32/33080_2.png) [@austingebauer](https://discuss.hashicorp.com/u/austingebauer)\
**Post date:** [October 26, 2020, 4:56pm UTC](https://discuss.hashicorp.com/t/vault-oidc-with-google-how-to-restrict-roles-to-specific-groups/14976/9 "2020-10-26T16:56:10Z")

</div>

@night-gold - It appears that the `bound_claims` issue you’re having related to limiting the role usage to a particular G Suite group is a bug. There is currently a Github issue open for it at: [https://github.com/hashicorp/vault-plugin-auth-jwt/issues/138](https://github.com/hashicorp/vault-plugin-auth-jwt/issues/138). You can track the status of the bug from that Github issue. This is on our radar now. We’ll be working to get this fixed.
