Skip to content

Commit

Permalink
[Fix] Fix security matcher configuration broken with update to Spring…
Browse files Browse the repository at this point in the history
… Security 6.
  • Loading branch information
ledsoft committed Sep 15, 2023
1 parent 53a2388 commit 18a6eac
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/cz/cvut/kbss/termit/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import java.util.Arrays;
import java.util.Collections;

import static org.springframework.security.web.util.matcher.AntPathRequestMatcher.antMatcher;

@ConditionalOnProperty(prefix = "termit.security", name = "provider", havingValue = "internal", matchIfMissing = true)
@Configuration
@EnableWebSecurity
Expand Down Expand Up @@ -88,8 +90,8 @@ public SecurityConfig(AuthenticationProvider authenticationProvider,
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
LOG.debug("Using internal security mechanisms.");
final AuthenticationManager authManager = buildAuthenticationManager(http);
http.authorizeHttpRequests((auth) -> auth.requestMatchers("/rest/query").permitAll()
.requestMatchers("/**").permitAll())
http.authorizeHttpRequests((auth) -> auth.requestMatchers(antMatcher("/rest/query")).permitAll()
.requestMatchers(antMatcher("/**")).permitAll())
.cors((auth) -> auth.configurationSource(corsConfigurationSource()))
.csrf(AbstractHttpConfigurer::disable)
.exceptionHandling(ehc -> ehc.authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED)))
Expand Down

0 comments on commit 18a6eac

Please sign in to comment.