Repository navigation
feat(starter): wire host TaskAuthorizationProvider into the request handler - #75
Merged
Merged
Conversation
…andler Hosts receiving A2A traffic (e.g. a workbench behind an MSB gateway) need a business-owned validation point before the agent executor runs. The A2A Java SDK already ships an operation-level authorization SPI; this exposes it in the starter: when a TaskAuthorizationProvider bean is present, the autoconfigured request handler wraps the default handler with the SDK's AuthorizationRequestHandlerDecorator so checkCreate guards message send/stream, checkRead/checkWrite guard task query, cancel, and subscribe, and rejections surface as standard A2A error envelopes. The decorator also carries CDI Instance fields, so it stays behind the SpringCompatibleRequestHandler facade like the delegate. Without such a bean the server is unchanged. Concrete use case: secondary authentication specifications require every provider-side call to be validated against signature headers (app-id/timestamp/sign-alg/sign/signature) before business execution. The A2AController already places all request headers into the ServerCallContext state, so a provider implementation reads them directly from the context and applies its validation steps. Includes context tests proving a rejecting provider stops the request before the executor and that the handler still assembles without one, plus API reference documentation (zh/en) with a usage example. Signed-off-by: tangzhiqiang <23572557+tangzhiqiang@users.noreply.github.com>
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.
What changed
Exposes the A2A Java SDK's operation-level authorization SPI in the Spring Boot starter. When a
TaskAuthorizationProviderbean is present, the autoconfiguredrequestHandleris wrapped with theSDK's
AuthorizationRequestHandlerDecorator, so host-side validation runs before the agentexecutor is invoked:
checkCreatemessage:send,message:stream(new task creation)checkRead/checkWriterecordOwnership/isTaskRecordedcheckCreatereturningfalsemaps to atask-not-found error, while throwing a more specific
A2AErrorsubclass carries a custom reason.Instancefields like the delegate, so it also stays behind theSpringCompatibleRequestHandlerfacade.ObjectProvider, so without such a bean the server isunchanged — no decorator is wired at all.
Why
Hosts receiving A2A traffic (e.g. a workbench behind an MSB gateway) need a business-owned
validation point before the agent executor runs. The secondary-authentication specification requires
every provider-side call to be validated against signature headers
(
app-id/timestamp/sign-alg/sign/signature) before business execution.A2AControlleralready places all request headers into the
ServerCallContextstate, so a provider implementationreads them directly from the context and applies its validation steps.
Breaking changes
None. The new constructor parameter is an
ObjectProvider, and therequestHandlerbean stays@ConditionalOnMissingBean, so an explicitly declared handler still wins.Test results
spring-boot-starter—A2AAutoConfigurationTest: 23 tests, 0 failures, 0 errorstaskAuthorizationProviderRejectionRunsBeforeTheAgentExecutor— asserts the executor isnever reached (
executorRuns == 0) and aTaskNotFoundErroris thrownrequestHandlerIsCreatedWithoutAnAuthorizationProvider— asserts the handler still assembleswith no provider present
workflow-engine— module build greenLocal note (not a regression): on the contributor's Windows machine the
samplesreactor fails withPortInUseException: Port 62478 is already in use(2 failures / 4 errors inSpringSpnDemoE2ETest).The identical failure — same port, same counts — reproduces on the pristine
6b1c2ecbaselinewithout this commit, so it is a local port-binding issue, not something this change introduces.
CI (
ubuntu-latest) is the authoritative gate for the samples module.Docs
docs/en/API_REFERENCE.mdanddocs/zh/API_REFERENCE.mdare updated in the same commit (zh/en keptin sync), documenting the
requestHandlerbehaviour plus a usage example.Related issues
No tracking issue exists for this change (searched the issue tracker for
TaskAuthorizationProviderand
authorization).