# How to use group, role, permission in rails backend code?

**URL:** <https://community.auth0.com/t/how-to-use-group-role-permission-in-rails-backend-code/6549>\
**Category:** Get Help\
**Tags:** rails, rails-api, knock, group, roles\
**Created:** [May 9, 2017, 6:07pm UTC](https://community.auth0.com/t/how-to-use-group-role-permission-in-rails-backend-code/6549 "2017-05-09T18:07:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemangj](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@hemangj](https://community.auth0.com/u/hemangj)\
**Post date:** [May 9, 2017, 6:07pm UTC](https://community.auth0.com/t/how-to-use-group-role-permission-in-rails-backend-code/6549/1 "2017-05-09T18:07:06Z")

</div>

We are passing jwt token and its get validated by auth0. In return we are receiving { “permissions”=\>“read:abc”], “groups”=\>“account”], “roles”=\>“external”]} in token.

We are integrating auth0 with [knock](https://github.com/nsarno/knock) gem in backend.

How we can further proceed with role, permission and group in rails.

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [May 23, 2017, 3:43pm UTC](https://community.auth0.com/t/how-to-use-group-role-permission-in-rails-backend-code/6549/2 "2017-05-23T15:43:45Z")

</div>

Based on their documentation Knock performs the verification of the JWT and trigger the availability of a user entity based on the token payload.

> By default, Knock assumes the payload as a subject (`sub`) claim containing the entity’s id and calls `find` on the model.

However, you can override that behavior by implementing a `from_token_payload` method that would allow you to create the user entity based on the full payload of the token which would mean you could create a user entity containing the permission, groups and roles contained in the token.

Given the user entity would then be available on authenticated routes you could then implement your access control by checking the `current_user` on each route.

---

<div class="post-metadata">

**Author:** ![hemangj](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@hemangj](https://community.auth0.com/u/hemangj)\
**Post date:** [June 12, 2017, 8:16pm UTC](https://community.auth0.com/t/how-to-use-group-role-permission-in-rails-backend-code/6549/3 "2017-06-12T20:16:38Z")

</div>

Hey thanks for your reply.

We have integrated [pundit](https://github.com/elabs/pundit) gem for authorization.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/how-to-use-group-role-permission-in-rails-backend-code/6549/4 "2018-03-02T05:53:48Z")

</div>


