# 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();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wannaqueen.gitbook.io/spring5/spring-boot/undefined-1/30.-by-ys/30.2-webflux.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
