mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-01 09:42:13 +00:00
SEC-2367: ProviderManager rethrows InternalAuthenticationServiceExceptions
This commit is contained in:
parent
7e274ea5b6
commit
fa39ecd719
@ -163,6 +163,9 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
|
|||||||
prepareException(e, authentication);
|
prepareException(e, authentication);
|
||||||
// SEC-546: Avoid polling additional providers if auth failure is due to invalid account status
|
// SEC-546: Avoid polling additional providers if auth failure is due to invalid account status
|
||||||
throw e;
|
throw e;
|
||||||
|
} catch (InternalAuthenticationServiceException e) {
|
||||||
|
prepareException(e, authentication);
|
||||||
|
throw e;
|
||||||
} catch (AuthenticationException e) {
|
} catch (AuthenticationException e) {
|
||||||
lastException = e;
|
lastException = e;
|
||||||
}
|
}
|
||||||
|
@ -287,6 +287,20 @@ public class ProviderManagerTests {
|
|||||||
verify(publisher).publishAuthenticationFailure(expected, authReq);
|
verify(publisher).publishAuthenticationFailure(expected, authReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SEC-2367
|
||||||
|
@Test
|
||||||
|
public void providerThrowsInternalAuthenticationServiceException() {
|
||||||
|
InternalAuthenticationServiceException expected = new InternalAuthenticationServiceException("Expected");
|
||||||
|
ProviderManager mgr = new ProviderManager(
|
||||||
|
Arrays.asList(createProviderWhichThrows(expected), createProviderWhichThrows(new BadCredentialsException("Oops"))), null);
|
||||||
|
final Authentication authReq = mock(Authentication.class);
|
||||||
|
|
||||||
|
try {
|
||||||
|
mgr.authenticate(authReq);
|
||||||
|
fail("Expected Exception");
|
||||||
|
} catch(InternalAuthenticationServiceException success) {}
|
||||||
|
}
|
||||||
|
|
||||||
private AuthenticationProvider createProviderWhichThrows(final AuthenticationException e) {
|
private AuthenticationProvider createProviderWhichThrows(final AuthenticationException e) {
|
||||||
AuthenticationProvider provider = mock(AuthenticationProvider.class);
|
AuthenticationProvider provider = mock(AuthenticationProvider.class);
|
||||||
when(provider.supports(any(Class.class))).thenReturn(true);
|
when(provider.supports(any(Class.class))).thenReturn(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user