fix(permissions): reload the users list on an unknown id or a denied access [PRD-1404] - #398
Conversation
…access [PRD-1404] A user or service account created after the agent started was unknown to it until the users cache expired (15 min by default), since nothing reloaded the list on an unknown id. Without SSE (the default outside production), or when the refresh-users event is lost, every call it made got a 403 meanwhile. - get_user_data reloads the users list once when the id is absent. - can? reloads the users on a denial, not only the collections permissions, so a role change applies right away. - Both reloads share a throttle: at most one per minute per process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (1)
🛟 Help
|
Scra3
left a comment
There was a problem hiding this comment.
Spec (PRD-1404): conforms. An unknown id and a can? denial both reload the users under one 60 s throttle per process, and the four required test cases are present.
…collections [PRD-1404] A user moved to a role that reads a related collection kept its fields redacted until the cache expired: the refetch reused the user loaded before it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scra3
left a comment
There was a problem hiding this comment.
Approved after /verify-fixes run 398-20260930120805-Scra3-verify: 1 findings of 398-20260930090500-Scra3 closed or accepted, none reopened.
## [1.44.4](v1.44.3...v1.44.4) (2026-10-01) ### Bug Fixes * **permissions:** reload the users list on an unknown id or a denied access [PRD-1404] ([#398](#398)) ([d375cb6](d375cb6))
|
🎉 This PR is included in version 1.44.4 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |

fixes PRD-1404
Why
A user or service account created after the agent started stayed unknown to it until the users cache expired (
permission_expiration, 900 s by default):get_user_datanever reloaded the list on an unknown id, socan?raisedForbiddenError.Only the SSE
refresh-usersevent could clear the cache sooner, andinstant_cache_refreshdefaults toRails.env.production?. Outside production, or when a proxy buffers the event stream, a service account created to be used right away got 403 for up to 15 min.A role change had the same delay: a denial only refetched the collections permissions, never the users.
What changes
ForestAdminAgent::Services::Permissions:get_user_datareloads the users list once when the id is absent.can_smart_action?,get_scopeand the read permissions go through it, so they benefit too.can?reloads the users on a denial, next to the existing collections refetch, viaget_user_data(caller.id, reload: true).fetch_read_permissionsdoes the same when a read denial refetches the collections, so a related collection a new role reads is no longer redacted until the cache expires.USERS_RELOAD_INTERVAL_IN_SECONDS(60 s) per process, so a bogus or removed id cannot trigger a burst of calls to the server. A TTL expiry or an SSE invalidation is not throttled.invalidate_cachewith no key also resets the throttle.The throttle is per process while the FileCache is shared by the workers of a machine: N workers can reload up to N times per minute.
Tests
permissions_spec.rb,/liana/v4/permissions/usersstubbed with sequential responses:related_read_permissions_spec.rb: a read denial reloads the caller, and a role changed since the last load reads the related collection at once.Five of the six fail without the fix; the known-id one guards against a regression. Package suite: 1264 examples, 0 failures. RuboCop clean.
🤖 Generated with Claude Code
Note
fixes PRD-1404
Why
A user or service account created after the agent started stayed unknown to it until the users cache expired (
permission_expiration, 900 s by default):get_user_datanever reloaded the list on an unknown id, socan?raisedForbiddenError.Only the SSE
refresh-usersevent could clear the cache sooner, andinstant_cache_refreshdefaults toRails.env.production?. Outside production, or when a proxy buffers the event stream, a service account created to be used right away got 403 for up to 15 min.A role change had the same delay: a denial only refetched the collections permissions, never the users.
What changes
ForestAdminAgent::Services::Permissions:get_user_datareloads the users list once when the id is absent.can_smart_action?,get_scopeand the read permissions go through it, so they benefit too.can?reloads the users on a denial, next to the existing collections refetch, viaget_user_data(caller.id, reload: true).fetch_read_permissionsdoes the same when a read denial refetches the collections, so a related collection a new role reads is no longer redacted until the cache expires.USERS_RELOAD_INTERVAL_IN_SECONDS(60 s) per process, so a bogus or removed id cannot trigger a burst of calls to the server. A TTL expiry or an SSE invalidation is not throttled.invalidate_cachewith no key also resets the throttle.The throttle is per process while the FileCache is shared by the workers of a machine: N workers can reload up to N times per minute.
Tests
permissions_spec.rb,/liana/v4/permissions/usersstubbed with sequential responses:related_read_permissions_spec.rb: a read denial reloads the caller, and a role changed since the last load reads the related collection at once.Five of the six fail without the fix; the known-id one guards against a regression. Package suite: 1264 examples, 0 failures. RuboCop clean.
🤖 Generated with Claude Code
Changes since #398 opened
ForestAdminAgent::Services::Permissions.fetch_read_permissionsto reload caller user data when a read permission denial triggers a forced collections permissions refetch [ef28c4d]ForestAdminAgent::Services::Permissionsreloads caller data on denial-triggered refetch [ef28c4d]