Validate Parameter in setPostAuthenticationChecks
The null check in setPostAuthenticationChecks of AbstractUserDetailsReactiveAuthenticationManager asserted the current field value, which is initialized to a default and can never be null, instead of the method parameter. As a result, null was silently accepted and the next authenticate call failed with a raw NullPointerException instead of failing fast with a clear message. Closes gh-19276 Signed-off-by: dae won <eodnjs01477@gmail.com>
This commit is contained in:
+1
-1
@@ -184,7 +184,7 @@ public abstract class AbstractUserDetailsReactiveAuthenticationManager
|
||||
* @since 5.2
|
||||
*/
|
||||
public void setPostAuthenticationChecks(UserDetailsChecker postAuthenticationChecks) {
|
||||
Assert.notNull(this.postAuthenticationChecks, "postAuthenticationChecks cannot be null");
|
||||
Assert.notNull(postAuthenticationChecks, "postAuthenticationChecks cannot be null");
|
||||
this.postAuthenticationChecks = postAuthenticationChecks;
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -90,6 +90,12 @@ public class UserDetailsRepositoryReactiveAuthenticationManagerTests {
|
||||
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> this.manager.setScheduler(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setPostAuthenticationChecksWhenNullThenIllegalArgumentException() {
|
||||
assertThatExceptionOfType(IllegalArgumentException.class)
|
||||
.isThrownBy(() -> this.manager.setPostAuthenticationChecks(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void authenticateWhenCustomSchedulerThenUsed() {
|
||||
given(this.scheduler.schedule(any())).willAnswer((a) -> {
|
||||
|
||||
Reference in New Issue
Block a user