Files
floci/src/main/java/io/github/hectorvent
Brian Taylorandlocal 908d70db3d fix(apigatewayv2): propagate Lambda REQUEST authorizer context to HTTP API backends (#2715)
* fix(apigatewayv2): propagate Lambda REQUEST authorizer context to HTTP API backends

A REQUEST authorizer's response context was parsed only to read isAuthorized
or the policy Effect, then discarded. enforceRequestAuthorizerV2 returned a
bare Response (null meaning "allowed"), so nothing could carry the context to
buildV2ProxyEvent and the backend Lambda received no requestContext.authorizer
at all. A real HTTP API delivers it under requestContext.authorizer.lambda,
which is how an authorizer hands verified identity to the integration, so a
backend that reads it sees an empty object and rejects every authorized
request.

This completes #1011 (issue #812), which added REQUEST authorizer invocation
for HTTP APIs but only wired the allow/deny decision, and brings v2 in line
with #581, which propagated the authorizer context on the v1/REST path. The
WebSocket $connect path already does the same via WebSocketProxyEventBuilder,
so HTTP APIs were the last of the three to drop it.

Return a RequestAuthorizerResult carrying the context, mirroring the
JwtAuthorizerResult the JWT path already threads through, and render it as
requestContext.authorizer.lambda.

Values are not flattened to strings the way the v1/REST path flattens its
authorizer context: an HTTP API hands the context to the integration as JSON.
The developer guide's own simple-response example returns a string, a number,
a boolean, an array and a map, and all five now survive to the backend.

principalId is deliberately left out - where AWS surfaces it in a 2.0 proxy
event was not measured - and an authorizer that allows without returning a
context leaves the authorizer node absent rather than rendering
"lambda": null, for the same reason.

Covered end to end in HttpApiRequestAuthorizerTest (IAM-policy and simple
responses, nesting and scalar types, contextless allow) and at the builder in
BuildV2ProxyEventLambdaAuthorizerTest.

* chore(apigatewayv2): trim comments on the authorizer-context change

Drops narration and change history, keeping only what is not recoverable from
the code: the RequestAuthorizerResult contract, why the context is not
flattened the way the v1/REST path flattens it, and the two intentional
omissions (principalId, absent node rather than "lambda": null).

Per AGENTS.md: prefer self-explanatory code over comments, document
intentional deviations clearly.

* fix(apigatewayv2): brace the authorizer error branch

AGENTS.md requires braces on every conditional.

---------

Co-authored-by: local <local@example.com>
2026-08-30 17:11:06 -04:00
..