Change Default for (Server)AuthenticationEntryPointFailureHandler
Closes gh-9429
This commit is contained in:
+2
-2
@@ -35,7 +35,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class AuthenticationEntryPointFailureHandler implements AuthenticationFailureHandler {
|
||||
|
||||
private boolean rethrowAuthenticationServiceException = false;
|
||||
private boolean rethrowAuthenticationServiceException = true;
|
||||
|
||||
private final AuthenticationEntryPoint authenticationEntryPoint;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class AuthenticationEntryPointFailureHandler implements AuthenticationFai
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to rethrow {@link AuthenticationServiceException}s (defaults to false)
|
||||
* Set whether to rethrow {@link AuthenticationServiceException}s (defaults to true)
|
||||
* @param rethrowAuthenticationServiceException whether to rethrow
|
||||
* {@link AuthenticationServiceException}s
|
||||
* @since 5.8
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ public class ServerAuthenticationEntryPointFailureHandler implements ServerAuthe
|
||||
|
||||
private final ServerAuthenticationEntryPoint authenticationEntryPoint;
|
||||
|
||||
private boolean rethrowAuthenticationServiceException = false;
|
||||
private boolean rethrowAuthenticationServiceException = true;
|
||||
|
||||
public ServerAuthenticationEntryPointFailureHandler(ServerAuthenticationEntryPoint authenticationEntryPoint) {
|
||||
Assert.notNull(authenticationEntryPoint, "authenticationEntryPoint cannot be null");
|
||||
@@ -54,7 +54,7 @@ public class ServerAuthenticationEntryPointFailureHandler implements ServerAuthe
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to rethrow {@link AuthenticationServiceException}s (defaults to false)
|
||||
* Set whether to rethrow {@link AuthenticationServiceException}s (defaults to true)
|
||||
* @param rethrowAuthenticationServiceException whether to rethrow
|
||||
* {@link AuthenticationServiceException}s
|
||||
* @since 5.8
|
||||
|
||||
+3
-3
@@ -30,17 +30,17 @@ import static org.mockito.Mockito.mock;
|
||||
public class AuthenticationEntryPointFailureHandlerTests {
|
||||
|
||||
@Test
|
||||
void onAuthenticationFailureWhenDefaultsThenAuthenticationServiceExceptionSwallowed() throws Exception {
|
||||
void onAuthenticationFailureWhenRethrowingThenAuthenticationServiceExceptionSwallowed() throws Exception {
|
||||
AuthenticationEntryPoint entryPoint = mock(AuthenticationEntryPoint.class);
|
||||
AuthenticationEntryPointFailureHandler handler = new AuthenticationEntryPointFailureHandler(entryPoint);
|
||||
handler.setRethrowAuthenticationServiceException(false);
|
||||
handler.onAuthenticationFailure(null, null, new AuthenticationServiceException("fail"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void handleWhenRethrowingThenAuthenticationServiceExceptionRethrown() {
|
||||
void handleWhenDefaultsThenAuthenticationServiceExceptionRethrown() {
|
||||
AuthenticationEntryPoint entryPoint = mock(AuthenticationEntryPoint.class);
|
||||
AuthenticationEntryPointFailureHandler handler = new AuthenticationEntryPointFailureHandler(entryPoint);
|
||||
handler.setRethrowAuthenticationServiceException(true);
|
||||
assertThatExceptionOfType(AuthenticationServiceException.class).isThrownBy(
|
||||
() -> handler.onAuthenticationFailure(null, null, new AuthenticationServiceException("fail")));
|
||||
}
|
||||
|
||||
+3
-3
@@ -71,16 +71,16 @@ public class ServerAuthenticationEntryPointFailureHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void onAuthenticationFailureWhenDefaultsThenAuthenticationServiceExceptionSwallowed() {
|
||||
void onAuthenticationFailureWhenRethrownFalseThenAuthenticationServiceExceptionSwallowed() {
|
||||
AuthenticationServiceException e = new AuthenticationServiceException("fail");
|
||||
this.handler.setRethrowAuthenticationServiceException(false);
|
||||
given(this.authenticationEntryPoint.commence(this.exchange, e)).willReturn(Mono.empty());
|
||||
this.handler.onAuthenticationFailure(this.filterExchange, e).block();
|
||||
}
|
||||
|
||||
@Test
|
||||
void handleWhenRethrowingThenAuthenticationServiceExceptionRethrown() {
|
||||
void handleWhenDefaultsThenAuthenticationServiceExceptionRethrown() {
|
||||
AuthenticationServiceException e = new AuthenticationServiceException("fail");
|
||||
this.handler.setRethrowAuthenticationServiceException(true);
|
||||
assertThatExceptionOfType(AuthenticationServiceException.class)
|
||||
.isThrownBy(() -> this.handler.onAuthenticationFailure(this.filterExchange, e).block());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user