> For the complete documentation index, see [llms.txt](https://wannaqueen.gitbook.io/spring5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wannaqueen.gitbook.io/spring5/spring-boot/undefined-1/30.-by-ys/30.2-webflux.md).

# 30.2 WebFlux 보안

Spring MVC 애플리케이션과 마찬가지로, `spring-boot-starter-security`종속성 을 추가하여 WebFlux 애플리케이션을 보호 할 수 있습니다 . 기본 보안 구성은 `ReactiveSecurityAutoConfiguration`및`UserDetailsServiceAutoConfiguration`에서 구현 됩니다. `ReactiveSecurityAutoConfiguration`은 웹 보안을 위해 `WebFluxSecurityConfiguration` 가져오고 `UserDetailsServiceAutoConfiguration` 인증을 구성하며 비 웹 응용 프로그램과도 관련이 있습니다. 기본 웹 응용 프로그램 보안 구성을 완전히 끄려면 `WebFilterChainProxyUserDetailsService` 유형의 빈을 추가하면됩니다 ( 구성 또는 액추에이터의 보안이 비활성화되지 않음 ).

또한 `UserDetailsService`설정을 끄려면, `ReactiveUserDetailsService`또는 `ReactiveAuthenticationManager` 타의 빈을 추가 할 수 있습니다.

액세스 규칙은 사용자 지정 `SecurityWebFilterChain`을 추가하여 구성 할 수 있습니다. 스프링 부트는 액츄에이터 끝점 및 정적 리소스에 대한 액세스 규칙을 무시하는 데 사용할 수있는 편리한 방법을 제공합니다. `EndpointRequest`을 사용하여 `management.endpoints.web.base-path`속성을 기반으로 하는 `ServerWebExchangeMatcher`를 작성할 수 있습니다.

`PathRequest`는 일반적으로 사용되는 위치의 리소스에 대한 `ServerWebExchangeMatcher` 를 만드는데 사용할 수 있습니다 .

예를 들어, 다음과 같이 추가하여 보안 구성을 사용자 정의 할 수 있습니다.

```java
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
	return http
		.authorizeExchange()
			.matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
			.pathMatchers("/foo", "/bar")
				.authenticated().and()
			.formLogin().and()
		.build();
}
```
