Skip to content

Commit

Permalink
Fix. Bruke AntPathRequestMatcher
Browse files Browse the repository at this point in the history
Co-authored-by: Jens Chr. Madsen <[email protected]>
Co-authored-by: Mathias Sand Jahren <[email protected]>
Co-authored-by: Martin Knutsen <[email protected]>
  • Loading branch information
4 people committed Oct 13, 2023
1 parent 7932184 commit bb6bf6e
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.oauth2.server.resource.authentication.JwtIssuerAuthenticationManagerResolver
import org.springframework.security.web.DefaultSecurityFilterChain
import org.springframework.security.web.util.matcher.AntPathRequestMatcher.antMatcher

@Configuration
@EnableWebSecurity
Expand All @@ -16,11 +18,11 @@ class SecurityConfig(
private val issuerResolver = JwtIssuerAuthenticationManagerResolver(issuers.split(','))

@Bean
fun configure(http: HttpSecurity) = http.run {
csrf().disable()
authorizeHttpRequests()
.requestMatchers("/actuator/**").permitAll()
.anyRequest().authenticated()
fun configure(http: HttpSecurity): DefaultSecurityFilterChain = http.run {
csrf { it.disable() }
authorizeHttpRequests {
it.requestMatchers(antMatcher("/actuator/**")).permitAll().anyRequest().authenticated()
}
oauth2ResourceServer {
it.authenticationManagerResolver(issuerResolver)
}
Expand Down

0 comments on commit bb6bf6e

Please sign in to comment.