Skip to content

Regression: ServerHttpSecurity ignore calls to permitAll() starting with 6.0.0-M7 #12074

Closed
@magnus-larsson

Description

@magnus-larsson

Describe the bug
Starting with Spring Security 6.0.0-M7 (used by Spring Boot 3.0.0-M5), calls to permitAll() when configuring ServerHttpSecurity seem to be ignored.

I'm working on preparing a Spring Boot 2.7-based application for Spring Boot 3.
When upgrading from Spring Boot 3.0.0-M4 to 3.0.0-M5, I started to get 401 on APIs that are configured to not require any authorization. The problem remains in Spring Boot 3.0.0-RC1.

To Reproduce

  1. Unzip the attached sample code.

  2. Build and start the server with: ./gradlew clean test bootRun

  3. Run the following three curl commands:

    curl localhost:8080/actuator/health -w ", %{http_code}\n"
    curl localhost:8080/api/open -w ", %{http_code}\n"
    curl localhost:8080/api/protected -w "%{http_code}\n"
    

    Expect them to return:

    {"status":"UP"}, 200
    {"result":"open"}, 200
    401
    
  4. Change the Spring Boot version in the file build.gradle to 3.0.0-M5 or 3.0.0-RC1

  5. Repeat steps 2 and 3. The responses from the curl commands will now be:

    , 401
    , 401
    401
    

Expected behavior

That the APIs configured to "permit-all" (/actuator/health and /api/open) do not return 401.

Sample
product-composite-service.zip

The Security configuration looks like:

@EnableWebFluxSecurity
public class SecurityConfig {

  @Bean
  SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
    http
      .authorizeExchange()
        .pathMatchers("/actuator/**").permitAll()
        .pathMatchers("/api/open").permitAll()
        .anyExchange().authenticated()
        .and()
      .oauth2ResourceServer()
        .jwt();
    return http.build();
  }
}

Metadata

Metadata

Labels

in: configAn issue in spring-security-configstatus: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions