53.3 HTTP endpoints 보안 by ys

다른 민감한 URL과 동일한 방식으로 HTTP 엔드 포인트를 보호해야합니다. Spring Security가 존재하면 스프링 보안의 컨텐츠 협상 전략을 사용하여 엔드 포인트가 기본적으로 보호됩니다. 예를 들어 특정 역할을 가진 사용자 만 액세스 할 수 있도록 HTTP 엔드 포인트에 대한 사용자 정의 보안을 구성하려는 경우 Spring Boot는 Spring Security와 함께 사용할 수있는 편리한RequestMatcher 오브젝트를 제공합니다 .

일반적인 스프링 보안 구성은 다음 예제와 유사합니다.

@Configuration
public class ActuatorSecurity extends WebSecurityConfigurerAdapter {

	@Override
	protected void configure(HttpSecurity http) throws
		http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests()
				.anyRequest().hasRole("ENDPOINT_ADMIN")
				.and()
			.httpBasic();
	}

}

앞의 예제는 EndpointRequest.toAnyEndpoint()사용하여 요청을 모든 엔드 포인트와 일치시킨 다음 모두 ENDPOINT_ADMIN역할을 갖도록합니다 .EndpointRequest 에서 다른 여러 가지 matcher 메소드도 사용할 수 있습니다 . 자세한 내용은 API 설명서 ( HTML 또는 PDF )를 참조하십시오.

방화벽 뒤에 응용 프로그램을 배포하는 경우 인증없이 모든 액추에이터 끝점에 액세스 할 수 있습니다. 다음과 같이 management.endpoints.web.exposure.include 속성 을 변경하면 됩니다.

application.properties.

management.endpoints.web.exposure.include=*

또한 Spring Security가있는 경우 다음 예제와 같이 엔드 포인트에 대한 인증되지 않은 액세스를 허용하는 사용자 정의 보안 구성을 추가해야합니다.

@Configuration
public class ActuatorSecurity extends WebSecurityConfigurerAdapter {

	@Override
	protected void configure(HttpSecurity http) throws Exception {
		http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests()
			.anyRequest().permitAll();
	}

}

Last updated