You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Permission now resolves against the query it was made from. It used to keep the fluent query's own state, so building another check on the same query before reading grantedAsync changed what the earlier one resolved: const q = ac.can('user', ctx); const del = q.deleteAny('vault'); q.readAny('public'); await del.grantedAsync answered for read on public, while del.action and del.resource still said delete and vault. Only checks that defer to the async path (a rule or require() gate with a { fn } condition, through can() or tryCan()) were affected; a sync check resolves when it is made.
ac.can(queryInfo) no longer writes the action and possession into the object you pass. A later top-level change to that object, or a change to a role array you passed (there or to role()), no longer reaches a check made from it. The context is still copied one level deep: a change to a nested object in it reaches a check that hasn't resolved yet.
An access or error listener gets copies of the roles and attributes, and each check from one query gets its own context copy, so a listener that edits the event no longer changes the permission or a sibling check.
Security
The fix above closes an authorization bypass in 3.0.0–3.1.2 (CWE-863): a reused query could turn a pending denial into an allow, or an allow into a denial. If you can't upgrade yet, make a new ac.can(role, context) for every check, never pass the same query object to more than one, or use checkAsync().