@@ -169,22 +169,33 @@ Refer to example [**`WebSecurityConfiguration`**](https://github.com/officiallys
169
169
private AuthenticationEntryPoint authenticationEntryPoint;
170
170
171
171
@Autowired
172
- private AccessDeniedHandler accessDeniedHandler
172
+ private AccessDeniedHandler accessDeniedHandler;
173
173
174
174
@Bean
175
175
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
176
176
// Your security configurations
177
- // http.csrf().disable()
178
- // .authorizeHttpRequests....
179
- // Security configurations......
180
-
181
- if (this . authenticationEntryPoint != null ) {
182
- http. exceptionHandling(). authenticationEntryPoint(this . authenticationEntryPoint);
177
+ http. csrf(AbstractHttpConfigurer :: disable)
178
+ .authorizeHttpRequests((requests) - > requests
179
+ .requestMatchers(" /swagger-resources/**" , " /swagger-ui/**" , " /swagger-ui.*" , " /v3/api-docs" , " /v3/api-docs/**" , " /webjars/**" )
180
+ .permitAll()
181
+ // .requestMatchers(
182
+ // // Add
183
+ // )
184
+ .permitAll()
185
+ .anyRequest()
186
+ .authenticated()
187
+ );
188
+
189
+ if (this . authenticationEntryPoint != null ) {
190
+ http. exceptionHandling(
191
+ exceptionHandling - >
192
+ exceptionHandling. authenticationEntryPoint(this . authenticationEntryPoint));
183
193
}
184
- if (this . accessDeniedHandler != null ) {
185
- http. exceptionHandling(). accessDeniedHandler(this . accessDeniedHandler);
194
+ if (this . accessDeniedHandler != null ) {
195
+ http. exceptionHandling(
196
+ exceptionHandling - > exceptionHandling. accessDeniedHandler(this . accessDeniedHandler));
186
197
}
187
-
198
+
188
199
return http. build();
189
200
}
190
201
```
@@ -201,20 +212,32 @@ Refer to example [**`WebFluxSecurityConfiguration`**](https://github.com/officia
201
212
private ServerAuthenticationEntryPoint authenticationEntryPoint;
202
213
203
214
@Autowired
204
- private ServerAccessDeniedHandler accessDeniedHandler
215
+ private ServerAccessDeniedHandler accessDeniedHandler;
205
216
206
217
@Bean
207
218
SecurityWebFilterChain securityWebFilterChain(final ServerHttpSecurity http) {
208
219
// Your security configurations
209
- // http.csrf().disable().authorizeExchange()
210
- // .pathMatchers....
211
-
212
- if (this . authenticationEntryPoint != null ) {
213
- http. exceptionHandling(). authenticationEntryPoint(this . authenticationEntryPoint);
220
+ http. csrf(ServerHttpSecurity . CsrfSpec :: disable)
221
+ .authorizeExchange((exchanges) - > exchanges
222
+ .pathMatchers(" /swagger-resources/**" , " /swagger-ui/**" , " /swagger-ui.*" , " /v3/api-docs" , " /v3/api-docs/**" , " /webjars/**" )
223
+ .permitAll()
224
+ // .pathMatchers(
225
+ // // Add
226
+ // )
227
+ .permitAll()
228
+ .anyExchange(). authenticated()
229
+ );
230
+
231
+ if (this . authenticationEntryPoint != null ) {
232
+ http. exceptionHandling(
233
+ exceptionHandling - >
234
+ exceptionHandling. authenticationEntryPoint(this . authenticationEntryPoint));
214
235
}
215
- if (this . accessDeniedHandler != null ) {
216
- http. exceptionHandling(). accessDeniedHandler(this . accessDeniedHandler);
236
+ if (this . accessDeniedHandler != null ) {
237
+ http. exceptionHandling(
238
+ exceptionHandling - > exceptionHandling. accessDeniedHandler(this . accessDeniedHandler));
217
239
}
240
+
218
241
return http. build();
219
242
}
220
243
```
0 commit comments