|
12 | 12 | import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; |
13 | 13 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
14 | 14 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
15 | | -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; |
16 | 15 | import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; |
17 | 16 | import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; |
18 | 17 | import org.springframework.security.config.http.SessionCreationPolicy; |
@@ -47,41 +46,41 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { |
47 | 46 | .frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin) |
48 | 47 | ).sessionManagement(conf -> conf.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) |
49 | 48 | .authorizeHttpRequests(authorize -> authorize |
50 | | - .requestMatchers(antMatcher("/api/v2/dev/**")).permitAll() |
51 | | - .requestMatchers(antMatcher("/api/v2/settings/license")).permitAll() |
| 49 | + .requestMatchers( |
| 50 | + antMatcher(WEBSOCKET_ENDPOINT), |
| 51 | + antMatcher(MLWORKER_WEBSOCKET_ENDPOINT), |
| 52 | + antMatcher(HttpMethod.OPTIONS, "/**"), |
| 53 | + antMatcher("/swagger-ui/**"), |
| 54 | + antMatcher("/v3/api-docs/**"), |
| 55 | + antMatcher("/test/**"), |
| 56 | + antMatcher("/api/v2/dev/**"), |
| 57 | + antMatcher("/api/v2/settings/license"), |
| 58 | + antMatcher("/api/v2/settings"), |
| 59 | + antMatcher("/api/v2/setup"), |
| 60 | + antMatcher("/api/v2/ee/license"), |
| 61 | + antMatcher("/api/v2/authenticate"), |
| 62 | + antMatcher("/api/v2/register"), |
| 63 | + antMatcher("/api/v2/register"), |
| 64 | + antMatcher("/api/v2/activate"), |
| 65 | + antMatcher("/api/v2/account/password-recovery"), |
| 66 | + antMatcher("/api/v2/account/reset-password"), |
| 67 | + antMatcher("/management/health"), |
| 68 | + antMatcher("/management/health/**"), |
| 69 | + antMatcher("/management/info"), |
| 70 | + antMatcher("/management/prometheus") |
| 71 | + ).permitAll() |
| 72 | + .requestMatchers( |
| 73 | + antMatcher("/api/admin/**"), |
| 74 | + antMatcher("/management/**") |
| 75 | + ).hasAuthority(AuthoritiesConstants.ADMIN) |
52 | 76 | .requestMatchers(antMatcher("/api/v2/settings/ml-worker-connect")).hasAuthority(AuthoritiesConstants.API) |
53 | | - .requestMatchers(antMatcher("/api/v2/settings")).permitAll() |
54 | | - .requestMatchers(antMatcher("/api/v2/setup")).permitAll() |
55 | | - .requestMatchers(antMatcher("/api/v2/ee/license")).permitAll() |
56 | | - .requestMatchers(antMatcher("/api/v2/authenticate")).permitAll() |
57 | | - .requestMatchers(antMatcher("/api/v2/register")).permitAll() |
58 | | - .requestMatchers(antMatcher("/api/v2/register")).permitAll() |
59 | | - .requestMatchers(antMatcher("/api/v2/activate")).permitAll() |
60 | | - .requestMatchers(antMatcher("/api/v2/account/password-recovery")).permitAll() |
61 | | - .requestMatchers(antMatcher("/api/v2/account/reset-password")).permitAll() |
62 | | - .requestMatchers(antMatcher("/api/admin/**")).hasAuthority(AuthoritiesConstants.ADMIN) |
63 | 77 | .requestMatchers(antMatcher("/api/**")).authenticated() |
64 | | - .requestMatchers(antMatcher("/management/health")).permitAll() |
65 | | - .requestMatchers(antMatcher("/management/health/**")).permitAll() |
66 | | - .requestMatchers(antMatcher("/management/info")).permitAll() |
67 | | - .requestMatchers(antMatcher("/management/prometheus")).permitAll() |
68 | | - .requestMatchers(antMatcher("/management/**")).hasAuthority(AuthoritiesConstants.ADMIN) |
69 | 78 | ) |
70 | 79 | .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) |
71 | 80 | .apply(securityConfigurerAdapter()); |
72 | 81 | return http.build(); |
73 | 82 | } |
74 | 83 |
|
75 | | - @Bean |
76 | | - public WebSecurityCustomizer webSecurityCustomizer() { |
77 | | - return web -> web.ignoring() |
78 | | - .requestMatchers(antMatcher(WEBSOCKET_ENDPOINT)) |
79 | | - .requestMatchers(antMatcher(MLWORKER_WEBSOCKET_ENDPOINT)) |
80 | | - .requestMatchers(antMatcher(HttpMethod.OPTIONS, "/**")) |
81 | | - .requestMatchers(antMatcher("/swagger-ui/**")) |
82 | | - .requestMatchers(antMatcher("/v3/api-docs/**")) |
83 | | - .requestMatchers(antMatcher("/test/**")); |
84 | | - } |
85 | 84 |
|
86 | 85 | @Bean |
87 | 86 | public PasswordEncoder passwordEncoder() { |
|
0 commit comments