Skip to content

Commit a1bdf93

Browse files
committed
Fix null-unsafe check in BasicAuthenticationFilter
1 parent 46ee6ed commit a1bdf93

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

web/src/main/java/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ protected boolean authenticationIsRequired(String username) {
217217
// Only reauthenticate if username doesn't match SecurityContextHolder and user
218218
// isn't authenticated (see SEC-53)
219219
Authentication existingAuth = this.securityContextHolderStrategy.getContext().getAuthentication();
220-
if (existingAuth == null || !existingAuth.getName().equals(username) || !existingAuth.isAuthenticated()) {
220+
if (existingAuth == null || existingAuth.getName() == null || !existingAuth.getName().equals(username)
221+
|| !existingAuth.isAuthenticated()) {
221222
return true;
222223
}
223224
// Handle unusual condition where an AnonymousAuthenticationToken is already

0 commit comments

Comments
 (0)