|
1 | 1 | # Overview |
2 | 2 |
|
3 | | -Here is a high level overview of the design and the requirements that shaped them: |
| 3 | +:::tip |
| 4 | + |
| 5 | +Read more on [Role Based Access Control in SeaORM 2.0](https://www.sea-ql.org/blog/2025-09-30-sea-orm-rbac/) blog post. |
| 6 | + |
| 7 | +::: |
| 8 | + |
| 9 | +Here is a high level overview of the design of SeaORM's RBAC: |
4 | 10 |
|
5 | | -### 1. Table‑level access control |
| 11 | +#### 1. Table‑level access control |
6 | 12 |
|
7 | 13 | Different user groups can only read or modify certain tables, e.g. customers can only read invoices, but not modify them. |
8 | 14 |
|
9 | 15 | Design: RBAC engine is table‑scoped so permissions can be expressed directly in terms of CRUD on tables. |
10 | 16 |
|
11 | | -### 2. Simplicity of user assignment |
| 17 | +#### 2. Simplicity of user assignment |
12 | 18 |
|
13 | 19 | Each user should have a clear, unambiguous role to avoid confusion. |
14 | 20 |
|
15 | 21 | Design: one user = one role. This prevents complexity of multiple roles per user. |
16 | 22 |
|
17 | | -### 3. Role hierarchy and inheritance |
| 23 | +#### 3. Role hierarchy and inheritance |
18 | 24 |
|
19 | 25 | We want to create roles that inherit from multiple roles like A = B + C where A will have the union of permissions from B and C. |
20 | 26 |
|
21 | 27 | We want to avoid duplicating permission sets across roles. For example, a 'Manager' should automatically get all 'Employee' permissions, plus extras. |
22 | 28 |
|
23 | 29 | Design: Hierarchical roles with multiple inheritance. |
24 | 30 |
|
25 | | -### 4. Granular, composable permissions |
| 31 | +#### 4. Granular, composable permissions |
26 | 32 |
|
27 | 33 | We need to allow fine‑grained control like 'read customers but not update them'. We want permission grant to be easy to reason about. |
28 | 34 |
|
29 | 35 | Design: Role can be assigned set of permissions (CRUD) on resources (tables). Permissions are additive, once granted, cannot be taken away (but can be overridden on a per user basis). |
30 | 36 |
|
31 | | -### 5. Extensibility |
| 37 | +#### 5. Extensibility |
32 | 38 |
|
33 | 39 | We want to extend beyond tables (e.g. application specific actions, or even non‑DB resources). |
34 | 40 |
|
35 | 41 | Design: Engine is generic - resource + permission abstraction can be applied to more than just CRUD operations on SQL tables. |
36 | 42 |
|
37 | | -### 6. Wildcard for convenience |
| 43 | +#### 6. Wildcard for convenience |
38 | 44 |
|
39 | 45 | Sometimes we need to grant superusers full access without enumerating every resource/permission. |
40 | 46 |
|
41 | 47 | Design: Opt‑in `*` wildcard for 'all permissions' or 'all resources.' |
42 | 48 |
|
43 | | -### 7. Per‑user overrides |
| 49 | +#### 7. Per‑user overrides |
44 | 50 |
|
45 | 51 | Occasionally, a single user needs an exception (e.g. a contractor who can only read one table, or a manager who should be denied one sensitive table). |
46 | 52 |
|
47 | 53 | Design: User‑level overrides to grant/deny permissions. |
48 | | - |
49 | | -:::tip |
50 | | - |
51 | | -Read more on [Role Based Access Control in SeaORM 2.0](https://www.sea-ql.org/blog/2025-09-30-sea-orm-rbac/) blog post. |
52 | | - |
53 | | -::: |
0 commit comments