mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(cognito): reject missing SRP challenge session (#4578)
Signed-off-by: xujiantop-crypto <265865031+xujiantop-crypto@users.noreply.github.com>
This commit is contained in:
1 parent
864f79cf31
commit
fbbbf244af
2 files changed
+20
-1
No files matched your search
+1
-1
@@ -578,7 +578,7 @@ final class CognitoAuthFlowHandler {
|
||||
clientMetadata);
|
||||
}
|
||||
|
||||
SrpSession srp = srpSessions.get(session);
|
||||
SrpSession srp = session == null ? null : srpSessions.get(session);
|
||||
if (srp == null) throw new AwsException("NotAuthorizedException", "Session not found", 400);
|
||||
if (sessionExpired(srp.expiresAt())) {
|
||||
srpSessions.remove(session);
|
||||
|
||||
@@ -2498,6 +2498,25 @@ class CognitoServiceTest {
|
||||
assertEquals("NotAuthorizedException", ex.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void passwordVerifierWithoutSessionReturnsNotAuthorized() {
|
||||
UserPool pool = service.createUserPool(Map.of("PoolName", "TestPool"), "us-east-1");
|
||||
UserPoolClient client = service.createUserPoolClient(pool.getId(), "c", false, false, List.of(), List.of());
|
||||
|
||||
AwsException userError = assertThrows(AwsException.class, () ->
|
||||
service.respondToAuthChallenge(client.getClientId(), "PASSWORD_VERIFIER", null, Map.of()));
|
||||
assertEquals("NotAuthorizedException", userError.getErrorCode());
|
||||
assertEquals("Session not found", userError.getMessage());
|
||||
assertEquals(400, userError.getHttpStatus());
|
||||
|
||||
AwsException adminError = assertThrows(AwsException.class, () ->
|
||||
service.adminRespondToAuthChallenge(pool.getId(), client.getClientId(),
|
||||
"PASSWORD_VERIFIER", null, Map.of()));
|
||||
assertEquals("NotAuthorizedException", adminError.getErrorCode());
|
||||
assertEquals("Session not found", adminError.getMessage());
|
||||
assertEquals(400, adminError.getHttpStatus());
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Auth challenge session expiry
|
||||
// =========================================================================
|
||||
|
||||
Reference in new issue
Block a user