mirror of
https://github.com/floci-io/floci.git
synced 2026-11-25 23:00:59 -05:00
7dc514b52f2c96bdd1ea32ae64a02703f85be2aa
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
fb82fb29ae |
fix(apigateway): answer an unmatched REST request with 403, not 404/405 (#3547)
* fix(apigateway): fall back to a parameterised sibling on method mismatch
A literal resource that declares some methods but not the requested one
returned 405 even when a parameterised sibling could serve it. Resource
candidates are ordered exact, then parameterised, then greedy, and the
selection loop stopped at the first candidate with any methods configured.
For /users/me declaring only PATCH, GET /users/me therefore returned 405
instead of resolving against /users/{userId}, where "me" is an ordinary
parameter value. Adding a literal child for one method silently removes
every other method a parameterised sibling already served, so this surfaces
as a regression in an application that was working.
The stop was there for a narrower reason, which the existing tests pin: a
method mismatch on a concrete resource must not be absorbed by a greedy
/{proxy+} catch-all. That rule is kept. Only the concrete-to-concrete case
changes, so a literal now yields to a parameterised sibling that can serve
the method, while /devices declaring POST still returns 405 for GET rather
than falling through to /{proxy+}.
Extends ApiGatewayRoutingFallthroughIntegrationTest, which already covers
the greedy cases, with /users/{userId} GET alongside a literal /users/me
PATCH: GET /users/me resolves to the parameterised resource, PATCH still
prefers the literal, and an ordinary id is unaffected.
* fix(apigateway): resolve the method against every matching resource
The selection loop stopped considering less specific siblings once a
resource declaring methods had been passed, so a method mismatch on a
concrete resource was terminal for the greedy half of the rule.
Captured against a real REST API in us-west-2: AWS picks the most
specific resource that can serve the requested method, searching
literal, then path parameter, then greedy {proxy+}, and refuses the
request only when no candidate declares it.
Drop concreteWithMethodsSeen and the greedy break so both fallbacks
follow that single rule. /users/me declaring only PATCH no longer hides
GET /users/{userId}, and /devices declaring only POST now falls through
to GET /{proxy+}.
getDevicesReturns405 pinned the greedy half of the old behaviour and is
updated to assert the fallthrough. Adds compatibility coverage for the
sibling and greedy fallbacks from the same AWS repro.
The no-match response is unchanged: AWS returns 403 Missing
Authentication Token where floci returns 405, tracked separately.
* fix(apigateway): answer an unmatched REST request with 403, not 404/405
A REST request that reached no method returned 404 "Not Found" when the
path matched nothing and 405 "Method Not Allowed" when it matched
resources declaring no usable method. AWS returns neither.
Captured against a real REST API in us-west-2 with /users/{userId} GET
and a literal /users/me PATCH deployed. POST /users/me, DELETE
/users/abc123, GET /zzz, GET /users/a/b/c and GET / all answered:
403 {"message":"Missing Authentication Token"}
x-amzn-ErrorType: MissingAuthenticationTokenException
AWS resolves the path and the method as one step, so an unknown path and
a known path carrying no usable method are the same failure and share one
response. This is the well-known "Missing Authentication Token" result of
calling a REST API with the wrong verb, which callers match on.
Route both branches through restNoMatch(), rendering the status, body and
error-type header AWS pairs with this failure, alongside the existing
AWS_IAM MISSING rejection that already returns that shape.
HTTP APIs are untouched: they answer an unmatched route with 404
{"message":"Not Found"}, which the v2 dispatch path continues to do.
* test(apigateway): expect 403 for a path that reaches no resource
ApiGatewayGreedyPathParameterIntegrationTest arrived on main after this
branch was cut, and pinned the old 404 for a REST path matching no
resource. This branch changes that contract to 403 "Missing Authentication
Token", so the assertion was stale rather than a real regression.
The test's intent is unchanged: /other/img/logo.png must not be swallowed
by the greedy resource. Only the no-match response it asserts moves.
HTTP API v2 is untouched and still answers an unmatched route with 404
"Not Found".
|
||
|
|
e8edc3d4b1 |
fix(apigateway): take the last value of a repeated query string parameter (#3548)
A REST proxy event built queryStringParameters from the FIRST value of a
repeated parameter, so ?x=1&x=2&x=3 reached the integration as "1".
Captured against a real REST API in us-west-2 with a Lambda proxy
integration: AWS collapses a repeated parameter to the LAST value,
yielding {"x":"3"}, while multiValueQueryStringParameters keeps every
value in order as ["1","2","3"]. A trailing empty value still wins, so
?x=1&x= yields "".
This is the same rule putSingleValueHeaders already applies to duplicate
request headers one method above, where the comment notes that taking the
first value diverged from AWS. Query strings were left on the old
behaviour; they now match.
Also pins two properties that were already correct, so they stay that
way: a bracketed name such as filter[status]=open reaches the integration
unchanged, and an absent query string nulls both maps.
putQueryStringParameters and putMultiValueQueryStringParameters become
package-private for the unit test, matching putSingleValueHeaders and
putMultiValueHeaders next to them.
HTTP APIs are untouched. Their payload formats join duplicates with a
comma rather than taking one value, which is a different rule and is not
measured here.
|
||
|
|
f03a716e90 |
fix(apigateway): fall back to a parameterised sibling on method mismatch (#3399)
* fix(apigateway): fall back to a parameterised sibling on method mismatch
A literal resource that declares some methods but not the requested one
returned 405 even when a parameterised sibling could serve it. Resource
candidates are ordered exact, then parameterised, then greedy, and the
selection loop stopped at the first candidate with any methods configured.
For /users/me declaring only PATCH, GET /users/me therefore returned 405
instead of resolving against /users/{userId}, where "me" is an ordinary
parameter value. Adding a literal child for one method silently removes
every other method a parameterised sibling already served, so this surfaces
as a regression in an application that was working.
The stop was there for a narrower reason, which the existing tests pin: a
method mismatch on a concrete resource must not be absorbed by a greedy
/{proxy+} catch-all. That rule is kept. Only the concrete-to-concrete case
changes, so a literal now yields to a parameterised sibling that can serve
the method, while /devices declaring POST still returns 405 for GET rather
than falling through to /{proxy+}.
Extends ApiGatewayRoutingFallthroughIntegrationTest, which already covers
the greedy cases, with /users/{userId} GET alongside a literal /users/me
PATCH: GET /users/me resolves to the parameterised resource, PATCH still
prefers the literal, and an ordinary id is unaffected.
* fix(apigateway): resolve the method against every matching resource
The selection loop stopped considering less specific siblings once a
resource declaring methods had been passed, so a method mismatch on a
concrete resource was terminal for the greedy half of the rule.
Captured against a real REST API in us-west-2: AWS picks the most
specific resource that can serve the requested method, searching
literal, then path parameter, then greedy {proxy+}, and refuses the
request only when no candidate declares it.
Drop concreteWithMethodsSeen and the greedy break so both fallbacks
follow that single rule. /users/me declaring only PATCH no longer hides
GET /users/{userId}, and /devices declaring only POST now falls through
to GET /{proxy+}.
getDevicesReturns405 pinned the greedy half of the old behaviour and is
updated to assert the fallthrough. Adds compatibility coverage for the
sibling and greedy fallbacks from the same AWS repro.
The no-match response is unchanged: AWS returns 403 Missing
Authentication Token where floci returns 405, tracked separately.
|
||
|
|
3a31c792fa |
fix(apigateway): populate full APIGatewayRequestAuthorizerEvent for REQUEST authorizers (#1002)
* fix: populate full APIGatewayRequestAuthorizerEvent for REQUEST authorizers Closes #807. Previously, REQUEST-type Lambda authorizers received only 'type' and 'methodArn'. This commit populates the complete event shape matching real AWS behavior: - headers, multiValueHeaders - queryStringParameters, multiValueQueryStringParameters - pathParameters (empty object when none, not null) - stageVariables (from Stage config, null when unconfigured) - requestContext with accountId, apiId, resourceId, resourcePath, path, httpMethod, stage, requestId, requestTimeEpoch - requestContext.identity with sourceIp, userAgent, apiKey, clientCert Also enriches the AWS_PROXY integration event (buildProxyEvent) with: - Full identity object (all null fields matching AWS wire format) - domainName, domainPrefix, protocol, requestTime, extendedRequestId - stageVariables from Stage configuration - API key resolution from usage plan keys Refactors shared logic into reusable helpers: - putSingleValueHeaders, putMultiValueHeaders - putQueryStringParameters, putMultiValueQueryStringParameters Resolves API key once per request (not duplicated across authorizer and proxy event builders). * fix: remove AWS SDK deps from main pom, rewrite test with RestAssured Addresses review feedback: AWS SDK dependencies should not be in the main Floci project. Rewrites ApiGatewayRequestAuthorizerIntegrationTest to use only RestAssured for management-plane and execute-api calls, matching the established pattern of all other @QuarkusTest tests. --------- Co-authored-by: Dixit R Jain <dixitrjain@Dixits-MacBook-Pro.local> Co-authored-by: Dixit R Jain <dixitrjain@Mac.lan> |