add security exc
package com.baeldung.reactive.security;
+import org.springframework.boot.actuate.autoconfigure.security.reactive.EndpointRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
@@ -9,6 +10,8 @@ import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.web.server.SecurityWebFilterChain;
+import com.baeldung.reactive.actuator.FeaturesEndpoint;
+
@EnableWebFluxSecurity
@EnableReactiveMethodSecurity
public class SecurityConfig {
@@ -16,10 +19,18 @@ public class SecurityConfig {
@Bean
public SecurityWebFilterChain securitygWebFilterChain(ServerHttpSecurity http) {
return http.authorizeExchange()
- .pathMatchers("/admin").hasAuthority("ROLE_ADMIN")
- .anyExchange().permitAll()
- .and().formLogin()
- .and().build();
+ .pathMatchers("/admin")
+ .hasAuthority("ROLE_ADMIN")
+ .matchers(EndpointRequest.to(FeaturesEndpoint.class))
+ .permitAll()
+ .anyExchange()
+ .permitAll()
+ .and()
+ .formLogin()
+ .and()
+ .csrf()
+ .disable()
+ .build();
}
@Bean
