Skip to content

Cannot unsecure actuator endpoints when using WebFlux #9476

@adenix

Description

@adenix

Describe the bug
When using Spring Security with WebFlux, /actuator can be unsecured but all other actuator endpoints cannot. The sample code below shows /actuator and /actuator/info being configured with .permitAll(). The former allows anonymous traffic but the latter returns 401 Unauthorized. This issues does not happen when using a servlet web app.

To Reproduce

  1. Create a new Spring Boot project using WebFlux, Actuator, and Spring Security
  2. Attempt to remove security from actuator endpoints other than the root /actuator

Expected behavior
Endpoints defined as .permitAll() without an overriding definition should allow anonymous access.

Sample
Demo Project
Reactive Security Bug.postman_collection.json.txt

@Configuration
@EnableWebFluxSecurity
@RequiredArgsConstructor
public class SecurityConfiguration {

  private final ReactiveAuthenticationManager authenticationManager;
  private final ServerSecurityContextRepository securityContextRepository;

  @Bean
  public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {

    http
        .csrf().disable()
        .formLogin().disable()
        .httpBasic().disable();

    http
        .authorizeExchange()
        .pathMatchers(HttpMethod.GET, "/actuator", "/actuator/info", "/demo").permitAll()
        .anyExchange().authenticated();

    http
        .authenticationManager(authenticationManager)
        .securityContextRepository(securityContextRepository);

    return http.build();
  }
}

Metadata

Metadata

Assignees

Labels

status: 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