Repository navigation
feat(agent): enforce authorization at tool execution boundary - #169
Merged
Merged
Conversation
…gentic-ai-java#120) Adds an opt-in authorization gate that runs before every tool dispatch, including retries, so that revoking access takes effect immediately.
yuluo-yx
pushed a commit
that referenced
this pull request
Oct 17, 2026
This was referenced Oct 18, 2026
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.
Describe what this PR does / why we need it
Adds opt-in authorization enforcement at the tool execution boundary, enabling applications to control which principals can invoke which tools based on runtime context.
This PR introduces:
Does this pull request fix one issue?
Fixes #120
Refs #117
Describe how you did it
AuthorizationDecisionas an immutable value type representing allow/deny outcomesToolAuthorizationPolicyfunctional interface as the application SPI, with three built-in static factory methods covering common casesToolAuthorizationInterceptorextendingToolInterceptor, which readsTrustedExecutionContextfromRunnableConfigand invokes the policy before forwarding to the next handlerBackgroundTaskto record the creating principal's tenantgetTask(id, callerTenantId)method toTaskRepositoryinterface as a default method; null caller has unrestricted accessDefaultTaskRepositoryand updatedTaskOutputToolto pass caller's tenantId from trusted execution contextDescribe how to verify it
Run the test suite:
All 18 tests pass, covering:
Special notes for reviews
Opt-in design: No ToolAuthorizationInterceptor is registered by default. Existing AgentToolNode configurations are unaffected and execute tools without authorization checks. Applications must explicitly add the interceptor to enable authorization.
Built-in policies reduce friction: The three factory methods (allowAll, denyAll, requireMatchingTenant) provide reasonable starting points without requiring a full custom policy implementation.
Execution order matters: ToolAuthorizationInterceptor should typically be placed early in the interceptor chain (before retry/fallback) so that revoked access takes effect immediately, including on retries.