Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ specs/
docs
.claude
*.bak
logs

### Developer's personal properties ###
**/resources/config/application*-dev-*.properties
Expand Down
9 changes: 4 additions & 5 deletions articles/EntityAccess_HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final AccessType READ = AccessType.READ;
public final AccessType WRITE = AccessType.WRITE;
```

- This enables expressions like `hasEntityAccess(#id, COHORT_DEFINITION, anyOf(READ, WRITE))` to resolve within `@PreAuthorize`.
- This enables expressions like `hasAnyEntityAccess(#id, COHORT_DEFINITION, anyOf(READ, WRITE))` to resolve within `@PreAuthorize`.

**Adding a new EntityType (summary steps)**

Expand All @@ -53,15 +53,14 @@ public final AccessType WRITE = AccessType.WRITE;
- Example annotation (place on controller or — preferably — the `CohortDefinitionService` method):

```java
@PreAuthorize("isOwner(#id, COHORT_DEFINITION) or isPermitted('read:cohort') or isPermitted('write:cohort') or hasEntityAccess(#id, COHORT_DEFINITION, anyOf(READ, WRITE))")
@PreAuthorize("isOwner(#id, COHORT_DEFINITION) or isPermitted(anyOf('read:cohort','write:cohort') or hasAnyEntityAccess(#id, COHORT_DEFINITION, anyOf(READ, WRITE))")
public CohortDTO getCohortDefinition(final int id) { ... }
```

- Explanation of the expression:
- `isOwner(#id, COHORT_DEFINITION)` — short-circuits grant if caller created/owns the entity.
- `isPermitted('read:cohort')` — grant based on a global permission.
- `isPermitted('write:cohort')` — write implies read; include if desired.
- `hasEntityAccess(#id, COHORT_DEFINITION, anyOf(READ, WRITE))` — delegate to `EntityAccessService` to check explicit grants for this entity id.
- `isPermitted(anyOf('read:cohort','write:cohort'))` — reading a definition is allowed granted global read/write.
- `hasAnyEntityAccess(#id, COHORT_DEFINITION, anyOf(READ, WRITE))` — delegate to `EntityAccessService` to check explicit grants for this entity id.

**Implementation checklist**

Expand Down
Loading
Loading