Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES-1993] blocking identifier when otps exhausted #478

Merged
merged 4 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ public GenerateChallengeResponse generateChallenge(GenerateChallengeRequest gene
String challenge = challengeManagerService.generateChallenge(transaction);
String challengeHash = IdentityProviderUtil.generateB64EncodedHash(IdentityProviderUtil.ALGO_SHA3_256, challenge);
transaction.setChallengeHash(challengeHash);

transaction.increaseAttempt();
if(transaction.getChallengeRetryAttempts() > resendAttempts) {
//Resend attempts exhausted, block the identifier for configured time.
cacheUtilService.blockIdentifier(transactionId, transaction.getIdentifier(), "blocked");
}

transaction.setLocale(generateChallengeRequest.getLocale());
cacheUtilService.createUpdateChallengeGeneratedTransaction(transactionId, transaction);

Expand Down Expand Up @@ -334,13 +340,6 @@ private void validateTransaction(RegistrationTransaction transaction, String ide
throw new SignUpException(ErrorConstants.IDENTIFIER_MISMATCH);
}

if(transaction.getChallengeRetryAttempts() > resendAttempts) {
log.error("generate-challenge failed: too many attempts, blocking the identifier");
//Resend attempts exhausted, block the identifier for configured time.
cacheUtilService.blockIdentifier(transactionId, transaction.getIdentifier(), "blocked");
throw new GenerateChallengeException(ErrorConstants.TOO_MANY_ATTEMPTS);
}

if(transaction.getLastRetryToNow() <= resendDelay) {
log.error("generate-challenge failed: too early attempts");
throw new GenerateChallengeException(ErrorConstants.TOO_EARLY_ATTEMPT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class ErrorConstants {
public static final String INVALID_CAPTCHA="invalid_captcha";
public static final String GENERATE_CHALLENGE_FAILED ="generate_challenge_failed";
public static final String UNKNOWN_ERROR="unknown_error";
public static final String TOO_MANY_ATTEMPTS="too_many_attempts";
public static final String TOO_MANY_VERIFY_ATTEMPTS="too_many_verify_attempts";
public static final String INVALID_REQUEST="invalid_request";
public static final String INVALID_CHALLENGE="invalid_challenge";
Expand Down
Loading