Is there a Spring interceptor that gets called before UsernamePasswordAuthenticationFilter?
I want to call a method before UsernamePasswordAuthenticationFilter.attemptAuthentication()
is called (and before any other requests are handled in the app).
I tried calling the method in HandlerInterceptorAdapter.preHandle()
but this is not triggered prior to attemptAuthentication()
although it takes care of other types of requests.
Is there a Spring inte开发者_StackOverflow社区rceptor that gets called before UsernamePasswordAuthenticationFilter
?
I guess you are talking about the spring security filter chain.
Filters with this names should be invoked before UsernamePasswordAuthenticationFilter
- FIRST
- CHANNEL_FILTER,
- CONCURRENT_SESSION_FILTER,
- SECURITY_CONTEXT_FILTER,
- LOGOUT_FILTER,
- X509_FILTER,
- PRE_AUTH_FILTER,
- CAS_FILTER,
See source code of org.springframework.security.config.http.SecurityFilters
for more details.
But you can also use before
:
<security:custom-filter ref="myFiler" before="FORM_LOGIN_FILTER" />
No - interceptors are part of Spring MVC which begins at DispatcherServlet
. Filters are called before servlets.
If you want to call something before UsernamePasswordAuthenticationFilter
it will need to be a filter inserted before that filter.
精彩评论