fix: entity auth filter - #56
Open
Akatuoro wants to merge 5 commits into
Open
Conversation
Akatuoro
marked this pull request as draft
August 12, 2026 14:33
Akatuoro
marked this pull request as ready for review
August 12, 2026 14:52
SummaryThe following content is AI-generated and provides a summary of the pull request: Fix: Entity Auth Filter for
|
| Issue | Description |
|---|---|
@requires on entities ignored |
@requires is valid on entities (shorthand for @restrict: [{grant:'*', to: role}]) but was not handled in checkEntityReadAccess |
@restrict with no to clause had wrong semantics |
Omitting to means the any pseudo-role (all users, including unauthenticated), but the old code only admitted authenticated users |
@restrict on actions ignored |
checkActionAccess only checked @requires; @restrict is also valid on actions (with grant implicitly treated as *) |
system-user pseudo-role unhandled |
No explicit handling existed alongside any and authenticated-user |
Refactor ♻️
Extracted two shared helpers to eliminate duplicated role-checking logic across all check functions:
_hasRole(user, role)— handlesany,authenticated-user,system-user, and custom roles_matchesToRoles(toRoles, user)— evaluates atoclause (absent =any), replacing inline role loops incheckEntityReadAccess,checkActionAccess, andcheckAuthorization
Tests ✅
Added a comprehensive integration test suite (tests/integration/auth-combinations.test.js) with a dedicated test service (AuthTestService) covering:
- Entity
@requires(single role, multiple roles) - Entity
@restrictwithREAD,*,WRITE-only, noto, multiple roles, multiple privileges - Action
@requiresand action@restrict - MCP call tool visibility rules
- Both MCP and OData surfaces verified to enforce permissions identically
Changelog
Updated CHANGELOG.md for version 1.4.3.
Have you...
- Added relevant entry to the change log?
- 🔄 Regenerate and Update Summary
- ✏️ Insert as PR Description (deletes this comment)
- 🗑️ Delete comment
PR Bot Information
Version: 1.29.26
- Summary Prompt: Default Prompt
- Output Template: Repository PR Template
- LLM:
anthropic--claude-4.6-sonnet - File Content Strategy: Full file content
- Correlation ID:
8014fca0-965d-11f1-96db-d131f9551d8d - Event Trigger:
pull_request.ready_for_review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Noticed some issues for entity-level require annotations. Only affects the context, actual authorization checks were still working. Here's the summary by claude:
@requireson entities was ignored — per CAP docs,@requiresis valid on entities (shorthand for@restrict: [{grant:'*', to: role}]). Added handling in checkEntityReadAccess.@restrictwith notoclause used wrong semantics — the old code only admitted authenticated users whentowas absent. Per docs, omittingtomeans the any pseudo-role → all users including unauthenticated are admitted. Fixed in _matchesToRoles.@restricton actions was ignored — checkActionAccess only checked@requires. Per docs,@restrictis also valid on actions (withgrantimplicitly treated as*; onlytois enforced). Added the check.The refactor also extracted _hasRole and _matchesToRoles helpers to eliminate the duplicated role-checking logic that existed across all three check functions.