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 interceptor that gets called before UsernamePasswordAuthenticationFilter
?
Filters can modify inbound and outbound requests and responses including modification of headers, entity and other request/response parameters. Interceptors are used primarily for modification of entity input and output streams. You can use interceptors for example to zip and unzip output and input entity streams.
The type WebSecurityConfigurerAdapter is deprecatedWell, it's because the developers of Spring framework encourage users to move towards a component-based security configuration.
Apart from authentication, spring security also check authorization of the logged in user. After login which user is authorize to access the resource is done on the bases of user's ROLE. At the time of creating user in WebSecurityConfig class, we can specify user?
I guess you are talking about the spring security filter chain.
Filters with this names should be invoked before UsernamePasswordAuthenticationFilter
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With