> For the complete documentation index, see [llms.txt](https://admincode.gitbook.io/admincode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://admincode.gitbook.io/admincode/overview/publish-your-docs/user-management-and-authorization.md).

# User management & Authorization

User authorization is a critical aspect of application security, ensuring that users can only access resources and perform actions that align with their roles and permissions. In this system, we implement a robust authorization mechanism using a combination of Role-Based Access Control (RBAC) and Entity-Based Access Control (EBAC). RBAC allows us to define and assign roles to users, where each role has specific permissions associated with it, simplifying the management of access control across different user groups. EBAC extends this model by providing fine-grained access control at the entity level, enabling more specific and contextual authorization decisions based on the individual resources or entities a user interacts with. Together, RBAC and EBAC offer a flexible, scalable, and secure approach to managing user access, ensuring that the system can accommodate both broad and granular authorization requirements.

***Let's see some examples***&#x20;

There are 3 users with 2 Roles, ROLE\_ADMIN and ROLE\_USER

user Admin is assigned ROLE\_ADMIN

user A and user B are assigned ROLE\_USER

Admin user assigns specific permissions to user’s A Role

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*5861OR2zjO2_9x3e8a3Osw.png" alt="" height="323" width="700"><figcaption><p>Administrator edits ROLE User to grant access</p></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*vklF0T3jzsuKxxDy_O8qLQ.png" alt="" height="313" width="700"><figcaption><p>Administrator gives access for READ/CREATE on Entity [Article], on ROLE_USER</p></figcaption></figure>

## Scenario A <a href="#a76d" id="a76d"></a>

user A creates a new Article record

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*Knhj56IRqzrWPPOejJ52GQ.png" alt="" height="247" width="700"><figcaption><p>userA with ROLE User logs in</p></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*DFXqorRjuFe6-8bXFk3W6g.png" alt="" height="277" width="700"><figcaption><p>userA creates a new Article</p></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*8JLlgHYpiZrD4-T-OLRTfw.png" alt="" height="245" width="700"><figcaption><p>userA tries to edit the Article</p></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*K_8MiI5zLASXrRJyf5WVDA.png" alt="" height="251" width="700"><figcaption><p>userA is denied updating the Article, as the ROLE_USER has no permission to update entity [Article]</p></figcaption></figure>

## Scenario B <a href="#b08e" id="b08e"></a>

Admin retrieves the Audit Log and reviews the changes …

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*ekiBJ0MVBKk74KEfs-xXSw.png" alt="" height="344" width="700"><figcaption><p>Admin user logs in</p></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*KylezlePc3i9Z7BUWWCDcg.png" alt="" height="329" width="700"><figcaption><p>Audit Log as per the creation of the new entity [Article]</p></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*B1w7gNwwurEH5ii2uk51kQ.png" alt="" height="336" width="700"><figcaption><p>Audit Log attribute details as per the creation of the new entity [Article]</p></figcaption></figure>

## Scenario C <a href="#id-61f7" id="id-61f7"></a>

User B logs in and searches Articles to view the new Article, created by user A. But user A and user B belong to different groups.

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*q2mpJjd5WnoZHTWL6Lqytw.png" alt="" height="295" width="700"><figcaption><p>user A belongs to group AUTHORS</p></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*rZYGGkStdNmUokFMCY7CBA.png" alt="" height="304" width="700"><figcaption><p>user B belongs to group DESIGNER</p></figcaption></figure>

<figure><img src="https://miro.medium.com/v2/resize:fit:1400/1*d9p6ZaeG03rFnDNGu1S8eQ.png" alt="" height="248" width="700"><figcaption><p>user B has no permission to retrieve Article created by user B, since they belong to 2 different groups</p></figcaption></figure>

<br>
