Skip to content

Commit 5830dd9

Browse files
authored
docs: update abac example (#2920)
1 parent bcc98ce commit 5830dd9

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

β€Ždocs/getting-started/modeling.mdxβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ Using the `action` or `permission` keywords yields the same authorization logic.
254254

255255
The `and` operator intersects the resolved user sets of its operands.
256256

257+
The same traversal rule applies to both `relation.userset` and `relation.permission`. If a relation points to multiple entities, Permify evaluates the referenced relation or permission across all related entities.
258+
257259
For an expression such as `org.member and org.admin`, Permify evaluates `org.member` and `org.admin` independently across all organizations reachable through `org`, and then intersects the resulting user sets.
258260

259261
Use this pattern when you want intersection across the users reachable through all related organizations:

β€Ždocs/use-cases/abac.mdxβ€Ž

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ Both of these conditions need to be true for the **`withdraw`** permission to be
334334

335335
In this model:
336336

337-
1. **`employee`**: Represents an individual worker. It has no specific attributes or relations in this case.
337+
1. **`employee`**: Represents the subject type used in the permission check. In this example, the permission logic does not depend on employee relations, so any employee subject would receive the same result.
338338
2. **`organization`**: Represents an entire organization, which has a **`founding_year`** attribute. The **`view`** permission is granted if the **`check_founding_year`** rule (which checks if the organization was founded after 2000) returns true.
339339
3. **`department`**: Represents a department within the organization. It has a **`budget`** attribute and a relation to its parent **`organization`**. The **`view`** permission is granted if the department's budget is more than 10,000 (checked by the **`check_budget`** rule) and if the **`organization.view`** permission is true.
340340

@@ -368,27 +368,39 @@ rule check_budget(budget double) {
368368
**Relationships**
369369

370370
- department:1#organization@organization:1
371-
- department:1#organization@organization:2
372371

373372
**Attributes**
374373

375374
- department:1$budget|double:20000
376-
- organization:1$organization|integer:2021
375+
- organization:1$founding_year|integer:2021
377376

378-
**Check Evolution Sub Queries For Department View**
377+
**Evaluation**
379378

380379
β†’ department:1$check_budget(budget) β†’ true
381380

382-
β†’ department:1#organization@user:1 β†’ true
383-
β†’ organization:2$check_founding_year(founding_year) β†’ false
384-
385381
β†’ organization:1$check_founding_year(founding_year) β†’ true
386382

387-
**Request keys before hash**
383+
β†’ department:1#view β†’ true
384+
385+
<Warning>
386+
If a department is related to multiple organizations, `organization.view` is evaluated across all related organizations. For example, if `department:1` is related to both `organization:1` and `organization:2`, and only one of them passes `view`, the traversal still succeeds because `relation.permission` uses union semantics across the related entities.
387+
388+
Example:
389+
390+
- department:1#organization@organization:1
391+
- department:1#organization@organization:2
392+
- department:1$budget|double:20000
393+
- organization:1$founding_year|integer:2021
394+
- organization:2$founding_year|integer:1990
395+
396+
Evaluation:
388397

389-
- `check*{snapshot}*{schema*version}*{context}\_department:1$check_budget(budget)` β†’ true
390-
- `check*{snapshot}*{schema*version}*{context}\_organization:2$check_founding_year(founding_year)` β†’ false
391-
- `check*{snapshot}*{schema*version}*{context}\_organization:1$check_founding_year(founding_year)` β†’ true
398+
- department:1$check_budget(budget) β†’ true
399+
- organization:1$check_founding_year(founding_year) β†’ true
400+
- organization:2$check_founding_year(founding_year) β†’ false
401+
- department:1#organization.view β†’ true
402+
- department:1#view β†’ true
403+
</Warning>
392404

393405
## Evaluation of ABAC Access Checks
394406

0 commit comments

Comments
Β (0)