From 5f1f7e300d4a19e01917be7c574559674fb28f5a Mon Sep 17 00:00:00 2001 From: "minseok.park" Date: Mon, 10 Mar 2025 08:57:10 +0900 Subject: [PATCH] Add validation for auth checks in AbstractUserDetailsAuthenticationProvider Add assertions to validate that preAuthenticationChecks and postAuthenticationChecks are not null during initialization. This allows errors to be detected earlier in the application lifecycle. Closes PR-16710 Signed-off-by: minseok.park --- .../dao/AbstractUserDetailsAuthenticationProvider.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java b/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java index 71199587ce0..d107f9aa22b 100644 --- a/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java +++ b/core/src/main/java/org/springframework/security/authentication/dao/AbstractUserDetailsAuthenticationProvider.java @@ -117,6 +117,8 @@ protected abstract void additionalAuthenticationChecks(UserDetails userDetails, public final void afterPropertiesSet() throws Exception { Assert.notNull(this.userCache, "A user cache must be set"); Assert.notNull(this.messages, "A message source must be set"); + Assert.notNull(this.preAuthenticationChecks, "A pre authentication checks must be set"); + Assert.notNull(this.postAuthenticationChecks, "A post authentication checks must be set"); doAfterPropertiesSet(); }