1
0
mirror of synced 2026-05-22 21:33:16 +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
committed by Marcus Hert Da Coregio
parent 6e6d472da4
commit 7fea639a43
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();
}
----
====