mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-28 14:52:24 +00:00
SEC-218: Fix authentication exception cleanup of SecurityContextHolder.
This commit is contained in:
parent
8cff715599
commit
57aee4e605
@ -129,18 +129,6 @@ public class RememberMeProcessingFilter implements Filter, InitializingBean,
|
|||||||
// Attempt authenticaton via AuthenticationManager
|
// Attempt authenticaton via AuthenticationManager
|
||||||
try {
|
try {
|
||||||
authenticationManager.authenticate(rememberMeAuth);
|
authenticationManager.authenticate(rememberMeAuth);
|
||||||
} catch (AuthenticationException authenticationException) {
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug(
|
|
||||||
"SecurityContextHolder not populated with remember-me token, as AuthenticationManager rejected Authentication returned by RememberMeServices: '"
|
|
||||||
+ rememberMeAuth
|
|
||||||
+ "'; invalidating remember-me token",
|
|
||||||
authenticationException);
|
|
||||||
}
|
|
||||||
|
|
||||||
rememberMeServices.loginFail(httpRequest, httpResponse);
|
|
||||||
chain.doFilter(request, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store to SecurityContextHolder
|
// Store to SecurityContextHolder
|
||||||
SecurityContextHolder.getContext()
|
SecurityContextHolder.getContext()
|
||||||
@ -160,6 +148,18 @@ public class RememberMeProcessingFilter implements Filter, InitializingBean,
|
|||||||
.getAuthentication(),
|
.getAuthentication(),
|
||||||
this.getClass()));
|
this.getClass()));
|
||||||
}
|
}
|
||||||
|
} catch (AuthenticationException authenticationException) {
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug(
|
||||||
|
"SecurityContextHolder not populated with remember-me token, as AuthenticationManager rejected Authentication returned by RememberMeServices: '"
|
||||||
|
+ rememberMeAuth
|
||||||
|
+ "'; invalidating remember-me token",
|
||||||
|
authenticationException);
|
||||||
|
}
|
||||||
|
|
||||||
|
rememberMeServices.loginFail(httpRequest, httpResponse);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user