Created
May 14, 2022 14:04
-
-
Save pablohdzvizcarra/f49d19474980dba6fcd7b571d8abff4e to your computer and use it in GitHub Desktop.
create bean with spring security configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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