1
0
mirror of synced 2026-08-05 01:36:56 +00:00

Add Option to Filter All Dispatcher Types

Closes gh-11092
This commit is contained in:
Marcus Da Coregio
2022-04-11 15:16:16 -03:00
parent da7db704eb
commit 84b5c76a7b
4 changed files with 132 additions and 1 deletions
@@ -169,3 +169,25 @@ SecurityFilterChain web(HttpSecurity http) throws Exception {
}
----
====
By default, the `AuthorizationFilter` does not apply to `DispatcherType.ERROR` and `DispatcherType.ASYNC`.
We can configure Spring Security to apply the authorization rules to all dispatcher types by using the `shouldFilterAllDispatcherTypes` method:
.Set shouldFilterAllDispatcherTypes to true
====
.Java
[source,java,role="primary"]
----
@Bean
SecurityFilterChain web(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((authorize) -> authorize
.shouldFilterAllDispatcherTypes(true)
.anyRequest.authenticated()
)
// ...
return http.build();
}
----
====