* 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>
* fix(cognito): correct USER_SRP_AUTH PASSWORD_VERIFIER signature
Server-side SRP-6a produced HMAC signatures that never matched what
AWS Amplify / SDKs compute, so USER_SRP_AUTH always failed with
NotAuthorizedException. Five independent bugs in the byte layout and
key-derivation chain:
1. SRP multiplier k: hashed N and g left-padded to N_BYTES (384 bytes).
Cognito/Amplify hash the minimal two's-complement representation
(385 bytes for N — sign byte prepended because MSB is set — and
1 byte for g = 2). k participates in both server B = k*v + g^b and
client S = (B - k*g^x)^(a+ux), so a divergent k breaks the protocol.
Use N.toByteArray() and G.toByteArray() directly.
2. Session key derivation: previously ran an undocumented "Caldera
interleaved hash" over S, then fed that into HKDF with a zero salt.
Cognito applies HKDF-Expand directly over S with the scrambling
parameter U as salt:
PRK = HMAC-SHA256(U_bytes, S_bytes)
T(1) = HMAC-SHA256(PRK, "Caldera Derived Key" || 0x01)
key = T(1)[0..16]
Inline that HKDF in computeSessionKey; drop interleaved hash + the
auxiliary hkdf() helper.
3. HKDF output length: helper returned 32 bytes; Amplify uses the first
16. Return Arrays.copyOf(t1, 16).
4. computeSignature double-HKDF: when sessionKey was already the final
HMAC key, computeSignature ran HKDF on it again. Use it as-is.
5. computeU / computeX byte layout: U was hashed with A and B
left-padded to N_BYTES; salt was decoded as raw hex bytes. Amplify
feeds the minimal two's-complement representation (with sign byte
for positive MSB-set values). Use BigInteger.toByteArray() for A/B
and round-trip the hex salt through BigInteger so a sign byte is
prepended when needed.
Verified by reproducing floci's exact server-side computation in
JavaScript using Amplify's byte conventions: the JS replay reproduces
floci's expected HMAC byte-for-byte (proving the server is internally
consistent) and the divergence from the client's claimed HMAC traces
entirely to k differing. After the fix, USER_SRP_AUTH end-to-end signin
from Amplify v6 (React Native) against floci succeeds.
Compat note: users whose verifier was stored under the previous
computeX with a salt whose first byte has the MSB set (~50% of
generate-salt outputs) will produce a different x and must reset their
password. New signups against this fix are interoperable with Amplify.
Also drops the now-unused padTo() helper.
* test(compatibility): add USER_SRP_AUTH round-trip tests for Node + Java SDKs
The existing CognitoSrpTest only validated that PASSWORD_VERIFIER was
returned by InitiateAuth; nothing exercised the full handshake. With the
server-side SRP math now spec-compliant, add end-to-end tests that prove
real AWS SDK clients authenticate against floci.
Java (sdk-test-java/CognitoSrpTest):
- Add step 4: compute PASSWORD_CLAIM_SIGNATURE from the challenge using
the AWS "Caldera" SRP variant, send RespondToAuthChallenge, assert
AuthenticationResult contains valid JWT id/access/refresh tokens.
- Helper math (computeX / computeU / computeK / calderaHkdf /
hmacSha256 / formatCognitoTimestamp) inlined since the AWS Java SDK
v2 does not expose a public SRP client.
Node (sdk-test-node/tests/cognito-srp.test.ts):
- New round-trip test using amazon-cognito-identity-js 6.3.16 — the
canonical JS SRP impl that @aws-amplify/auth wraps internally.
- Pool is provisioned via AdminCreateUser + AdminSetUserPassword so the
test doesn't depend on an email-delivered verification code.
- Validates tokens come back as well-formed JWTs.
Both tests pass against floci with the fix from the previous commit and
fail (CodeMismatchException / NotAuthorizedException) without it.
* feat: implement API Gateway v2 WebSocket data-plane support Implement full WebSocket data-plane for API Gateway v2, including: - Real WebSocket connection handling via Vert.x (ws://localhost:4566/ws/{apiId}/{stage}) - $connect/$disconnect/$default route lifecycle with Lambda integration - Custom route selection via routeSelectionExpression ($request.body.{field}) - @connections management API (POST/GET/DELETE) for server-to-client messaging - Lambda REQUEST authorizer support on $connect with identity source validation - Stage variable substitution in integration URIs - Multiple integration types: AWS_PROXY, AWS (VTL), HTTP_PROXY, HTTP (VTL), MOCK - Route response selection expression for bidirectional messaging - Binary frame support (isBase64Encoded: true) - 128 KB payload size limit enforcement (frames and @connections POST) - 10-minute idle timeout and 2-hour max connection duration - GoneException (410) for disconnected connections - $connect response headers propagation - Server-initiated close via @connections DELETE (skips $disconnect Lambda) Also includes: - Refactored LambdaArnUtils.extractFunctionNameFromUri as shared utility - Extended Authorizer/Integration/Stage models with new fields - Comprehensive Java integration tests (WebSocket lifecycle, routing, auth, etc.) - Node.js SDK compatibility tests using ws client and @aws-sdk/client-apigatewaymanagementapi - Updated documentation with full feature matrix
* test(apigatewayv2): support custom WebSocket endpoint via env var
- Update wsUrl helper to read FLOCI_ENDPOINT environment variable
- Convert http/https schemes to ws/wss for WebSocket compatibility
- Strip trailing slashes from endpoint URL for consistent formatting
- Enable testing against non-localhost endpoints for CI/CD flexibility
* fix: use AwsErrorResponse for @connections API error responses
Replace raw JSON string literals in handlePostToConnection,
handleGetConnectionInfo, and handleDeleteConnection with the
project-standard AwsErrorResponse record, which serialises to
the correct {"__type": ..., "message": ...} wire shape.
* fix: simplify extractFunctionNameFromUri using AwsArnUtils.parse
Adopt AwsArnUtils.parse() as the core of the implementation per
reviewer suggestion. One addition beyond the suggested snippet:
the API Gateway v1 integration URI format embeds a Lambda ARN
inside an apigateway ARN (resource starts with 'path/.../functions/'),
so we detect that pattern and recurse on the embedded ARN before
applying the standard function-name extraction. All 43
LambdaArnUtilsTest cases pass, including the API Gateway v1 style URI.
* feat(eventbridge): add InputTransformer support for rule targets
Support InputPathsMap + InputTemplate on EventBridge targets so events
can be projected to a subset of fields before delivery to SQS/SNS/Lambda.
- Add InputTransformer model with inputPathsMap and inputTemplate fields
- Parse and serialize InputTransformer in PutTargets / ListTargetsByRule
- Apply transformer in invokeTarget: extract JSONPath variables, substitute
<varName> placeholders in the template
- Use Jackson JsonPointer for JSONPath resolution ($.a.b.c → /a/b/c)
- Add unit tests for extractJsonPath and applyInputTransformer edge cases
- Add integration tests covering full put/list/deliver/transform flow
Fixes#140
* test: move compatibility tests into this repo
* fix: add StatisticValues parsing to CloudWatchMetricsJsonHandler
* fix: add missing required abstract methods to EmulatorConfig in EventBridgeSchedulerIntegrationTest
* test: add sdk tests for multipart S3 copy coverage
* fix: cover and fix smithy cbor and multipart s3 copy regressions
* test: migrate more test coverage to new folder
* test: add missing ec2 expectation in healthcheck test
* docs: update READMEs in `./compatibility-tests`