Skip to content

Commit 880b2b6

Browse files
Updated Spring boot version to 3.2.0
1 parent 06782d2 commit 880b2b6

File tree

1 file changed

+41
-18
lines changed

1 file changed

+41
-18
lines changed

README.md

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,33 @@ Refer to example [**`WebSecurityConfiguration`**](https://github.com/officiallys
169169
private AuthenticationEntryPoint authenticationEntryPoint;
170170

171171
@Autowired
172-
private AccessDeniedHandler accessDeniedHandler
172+
private AccessDeniedHandler accessDeniedHandler;
173173

174174
@Bean
175175
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
176176
// 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));
183193
}
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));
186197
}
187-
198+
188199
return http.build();
189200
}
190201
```
@@ -201,20 +212,32 @@ Refer to example [**`WebFluxSecurityConfiguration`**](https://github.com/officia
201212
private ServerAuthenticationEntryPoint authenticationEntryPoint;
202213

203214
@Autowired
204-
private ServerAccessDeniedHandler accessDeniedHandler
215+
private ServerAccessDeniedHandler accessDeniedHandler;
205216

206217
@Bean
207218
SecurityWebFilterChain securityWebFilterChain(final ServerHttpSecurity http) {
208219
// 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));
214235
}
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));
217239
}
240+
218241
return http.build();
219242
}
220243
```

0 commit comments

Comments
 (0)