You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<1> Lazily get Filter that was registered as a Spring Bean.
77
58
For the example in <<servlet-delegatingfilterproxy-figure>> `delegate` is an instance of __Bean Filter~0~__.
78
59
<2> Delegate work to the Spring Bean.
@@ -155,58 +136,7 @@ However, there are times that it is beneficial to know the ordering, if you want
155
136
These security filters are most often declared using an javadoc:org.springframework.security.config.annotation.web.builders.HttpSecurity[`HttpSecurity`] instance.
156
137
To exemplify the above paragraph, let's consider the following security configuration:
157
138
158
-
[tabs]
159
-
======
160
-
Java::
161
-
+
162
-
[source,java,role="primary"]
163
-
----
164
-
@Configuration
165
-
@EnableWebSecurity
166
-
public class SecurityConfig {
167
-
168
-
@Bean
169
-
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
The above configuration will result in the following `Filter` ordering:
212
142
@@ -233,7 +163,7 @@ If you want to see the list of filters invoked for a particular request, you can
233
163
=== Printing the Security Filters
234
164
235
165
Often times, it is useful to see the list of security ``Filter``s that are invoked for a particular request.
236
-
For example, you want to make sure that the <<adding-custom-filter,filter you have added>> is in the list of the security filters.
166
+
For example, you want to make sure that the <<adding-filters-to-chain,filter you have added>> is in the list of the security filters.
237
167
238
168
The list of filters is printed at DEBUG level on the application startup, so you can see something like the following on the console output for example:
239
169
@@ -248,7 +178,7 @@ But that is not all, you can also configure your application to print the invoca
248
178
That is helpful to see if the filter you have added is invoked for a particular request or to check where an exception is coming from.
249
179
To do that, you can configure your application to <<servlet-logging,log the security events>>.
250
180
251
-
[[adding-custom-filter]]
181
+
[[adding-filters-to-chain]]
252
182
=== Adding Filters to the Filter Chain
253
183
254
184
Most of the time, the default <<servlet-security-filters>> are enough to provide security to your application.
@@ -349,34 +248,7 @@ The previous description already gives us a clue on where to add the filter, sin
349
248
350
249
Based on the rule of thumb, add it after xref:servlet/authentication/anonymous.adoc[ `AnonymousAuthenticationFilter`], the last authentication filter in the chain, like so:
In this case, remove the call to `httpBasic` since you are constructing `BasicAuthenticationFilter` yourself.
531
299
532
300
[TIP]
533
301
====
534
302
In the event that you are unable to reconfigure `HttpSecurity` to not add a certain filter, you can typically disable the Spring Security filter by calling its DSL's `disable` method like so:
0 commit comments