Skip to content

Commit cb2dc21

Browse files
changed method 'securityFilterChain()' to SecurityConfig.java
1 parent 6d635b4 commit cb2dc21

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/main/java/hexlet/code/config/SecurityConfig.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
1313
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
1414
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
15-
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
1615
import org.springframework.security.config.http.SessionCreationPolicy;
1716
import org.springframework.security.crypto.password.PasswordEncoder;
1817
import org.springframework.security.oauth2.jwt.JwtDecoder;
@@ -33,15 +32,17 @@ SecurityFilterChain securityFilterChain(HttpSecurity http, HandlerMappingIntrosp
3332
throws Exception {
3433

3534
return http
36-
.csrf(AbstractHttpConfigurer::disable)
35+
.csrf(csrf -> csrf.ignoringRequestMatchers("/", "/api/*"))
3736
.authorizeHttpRequests(auth -> auth
38-
.requestMatchers("/").permitAll()
39-
.requestMatchers("/index.html").permitAll()
40-
.requestMatchers("/welcome").permitAll()
41-
.requestMatchers("/api/login").permitAll()
42-
.requestMatchers("/assets/**").permitAll()
43-
.requestMatchers("/v3/api-docs/**").permitAll()
44-
.requestMatchers("/swagger-ui.html", "/swagger-ui/**", "/swagger-ui/index.html").permitAll()
37+
.requestMatchers(
38+
"/",
39+
"/index.html",
40+
"/api/login",
41+
"/assets/**",
42+
"/v3/api-docs/**",
43+
"/swagger-ui.html",
44+
"/swagger-ui/**")
45+
.permitAll()
4546
.anyRequest().authenticated())
4647
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
4748
.oauth2ResourceServer((rs) -> rs.jwt((jwt) -> jwt.decoder(jwtDecoder)))

0 commit comments

Comments
 (0)