add security exc
This commit is contained in:
parent
9101461a0a
commit
8b5232c1b6
|
@ -1,5 +1,6 @@
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue