fix: do not bypass permission grants for agent-created resources#142
Draft
sayakmaity wants to merge 1 commit intomainfrom
Draft
fix: do not bypass permission grants for agent-created resources#142sayakmaity wants to merge 1 commit intomainfrom
sayakmaity wants to merge 1 commit intomainfrom
Conversation
When agents create tasks via ACP, the authorization service was incorrectly bypassing the grant() operation due to _bypass() returning True when agent_identity is set. This caused permission records to not be created, resulting in 403 Forbidden errors when users tried to view agent-created tasks from the SGP UI. This fix splits the bypass logic into two methods: - _bypass_check(): Used for check() and list_resources() - bypasses when agent_identity is set OR authorization is disabled (preserves existing agent-to-agent trust behavior) - _bypass_write(): Used for grant() and revoke() - only bypasses when authorization is disabled, NOT when agent_identity is set (ensures permission records are always created) Root cause: Tasks created by agents had no permission records, so when users accessed them via the UI, the permission check failed even though the user had role-based access to the account.
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.
Summary
Fixes the authorization bypass bug that caused 403 Forbidden errors when users tried to view agent-created tasks from the SGP UI.
Root Cause: When agents create tasks via ACP,
authorization_service._bypass()was returningTruebecauseagent_identityis set. This causedgrant()to skip creating permission records, so users couldn't access those tasks later even with proper role-based access.The Fix: Split the bypass logic into two methods:
_bypass_check(): Used forcheck()andlist_resources()- bypasses whenagent_identityis set OR authorization is disabled (preserves existing agent-to-agent trust behavior)_bypass_write(): Used forgrant()andrevoke()- only bypasses when authorization is disabled, NOT whenagent_identityis set (ensures permission records are always created)Evidence
From SGP staging logs, multiple 403 errors for task
f46e8192-2cca-415c-95e3-27f5867ea418:Infrastructure was healthy (RDS CPU 8-9%, replica lag 15-25ms, Redis 1% CPU) - confirming this is an application-level bug, not infrastructure.
Test plan
Related
6939c7450f636b79305ab5ce([Demo] Financial Services)