Skip to content

FIX: Removed unnecessary warn logs that are part of the login flow #39

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

Merged
merged 2 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -6,7 +6,6 @@
import nl._42.restsecure.autoconfigure.authentication.RegisteredUser;
import nl._42.restsecure.autoconfigure.authentication.UserDetailsAdapter;

import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.AuthenticationException;
Expand Down Expand Up @@ -65,7 +64,7 @@ protected void additionalAuthenticationChecks(UserDetails userDetails, UsernameP
private void executeMfaVerificationSteps(MfaAuthenticationToken mfaAuthenticationToken, UserDetailsAdapter<? extends RegisteredUser> userDetailsAdapter) {
// If no code supplied, indicate a code is needed.
if (mfaAuthenticationToken.getVerificationCode() == null || mfaAuthenticationToken.getVerificationCode().isEmpty()) {
throw new InsufficientAuthenticationException(SERVER_MFA_CODE_REQUIRED_ERROR);
throw new MfaRequiredException(SERVER_MFA_CODE_REQUIRED_ERROR);
}
boolean verificationSucceeded = false;
for (MfaVerificationCheck verificationCheck : verificationChecks) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package nl._42.restsecure.autoconfigure.authentication.mfa;

import org.springframework.security.authentication.InsufficientAuthenticationException;

public class MfaRequiredException extends InsufficientAuthenticationException {

public MfaRequiredException(String msg) {
super(msg);
}

public MfaRequiredException(String msg, Throwable cause) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deze constructor wordt toch niet gebruikt? Kan eventueel ook gewoon direct van RuntimeException erven.

super(msg, cause);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package nl._42.restsecure.autoconfigure.errorhandling;

import nl._42.restsecure.autoconfigure.authentication.mfa.MfaRequiredException;
import nl._42.restsecure.autoconfigure.form.LoginForm;

import org.slf4j.Logger;
Expand All @@ -9,10 +10,11 @@ public class LogUtil {
private LogUtil() {}

public static <T extends LoginForm> void logAuthenticationFailure(Logger log, T form, RuntimeException exception) {
if (log.isDebugEnabled()) {
// Filter out logs that are part of the login flow
if (log.isDebugEnabled() || exception instanceof MfaRequiredException || form.username == null) {
log.debug("Authentication failure for user '{}'! {}", form.username, exception.getMessage(), exception);
} else {
log.warn("Authentication failure for user '{}'! {}", form.username, exception.getMessage());
return;
}
log.warn("Authentication failure for user '{}'! {}", form.username, exception.getMessage());
}
}
Loading