mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(cognito): reject invalid refresh tokens in InitiateAuth REFRESH_TOKEN_AUTH (#2132)
* fix(cognito): reject invalid refresh tokens in InitiateAuth REFRESH_TOKEN_AUTH InitiateAuth with AuthFlow=REFRESH_TOKEN_AUTH silently fell back to minting fresh tokens for a fake "unknown" user whenever the supplied REFRESH_TOKEN failed to parse or didn't resolve to a real user, instead of failing like GetTokensFromRefreshToken already does. Fixes #2113 * test(cognito): add regression tests for invalid refresh token rejection Cover InitiateAuth REFRESH_TOKEN_AUTH with a garbage token and with a well-formed token encoding a nonexistent user; both must fail with NotAuthorizedException rather than returning an AuthenticationResult. * test(cognito): add regression test for non-numeric refresh token issued-at Covers a well-formed refresh token whose issued-at field is not a number; must fail with 400 NotAuthorizedException rather than the 500 NumberFormatException that surfaced before the parse was guarded. * fix(ec2): make network interface pagination tests order-independent describeNetworkInterfacesWithMaxResultsNoNextToken and describeNetworkInterfacesMultipagePagination assumed a fixed/low ENI count, but other tests in this class are not isolated and can leave ENIs behind depending on JUnit's tie-breaking order among tests sharing @Order(92). Use MaxResults=1000 for the single-page case and measure the actual ENI baseline before asserting page counts for the multipage case.
This commit is contained in:
1 parent
50fe67dde6
commit
3ce5041c71
3 files changed
+142
-34
No files matched your search
+11
-1
@@ -246,7 +246,17 @@ final class CognitoAuthFlowHandler {
|
||||
// Check revocation before issuing new tokens
|
||||
service.validateRefreshTokenNotRevoked(refreshTokenUuid, pool.getId(), username, iat);
|
||||
|
||||
CognitoUser user = service.adminGetUser(pool.getId(), username);
|
||||
CognitoUser user;
|
||||
try {
|
||||
user = service.adminGetUser(pool.getId(), username);
|
||||
} catch (AwsException ae) {
|
||||
// Real Cognito never reveals whether the encoded username exists; any
|
||||
// refresh token that doesn't resolve to a real user is simply invalid.
|
||||
if ("UserNotFoundException".equals(ae.getErrorCode())) {
|
||||
throw new AwsException("NotAuthorizedException", "Invalid Refresh Token", 400);
|
||||
}
|
||||
throw ae;
|
||||
}
|
||||
CognitoService.ClaimsOverride override = firePreTokenGeneration(pool, client, user,
|
||||
clientMetadata, "TokenGeneration_RefreshTokens");
|
||||
Map<String, Object> auth = new HashMap<>();
|
||||
|
||||
Reference in new issue
Block a user