Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pablohdzvizcarra/f49d19474980dba6fcd7b571d8abff4e to your computer and use it in GitHub Desktop.
Save pablohdzvizcarra/f49d19474980dba6fcd7b571d8abff4e to your computer and use it in GitHub Desktop.
create bean with spring security configuration
package com.baeldung.springreactivebaeldungseries.lesson01;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
@EnableWebFluxSecurity
public class EmployeeWebSecurityConfig {
@Bean
public SecurityWebFilterChain springSecurityFilterChain(
ServerHttpSecurity http) {
return http
.csrf().disable()
.authorizeExchange()
.pathMatchers(HttpMethod.POST, "/employees/update").hasRole("ADMIN")
.pathMatchers("/**").permitAll()
.and()
.httpBasic()
.and().build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment