如何为Hystrix.stream启用Spring Boot Security Basic身份验证?

时间:2017-02-22 06:14:00

标签: spring spring-security hystrix

我需要启用http://localhost:8080/hystrix.stream的基本身份验证。

我添加了Spring Security它保护除hystrix.stream之外的所有其他端点。

是否可以使用Spring Boot Security基本身份验证来保护hystrix.stream。

1 个答案:

答案 0 :(得分:1)

首先,您需要为管理端点启用安全性:

management.security.enabled = true

接下来,您可以像对待任何其他端点一样配置对hystrix.stream的访问权限:

@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
            .antMatcher("/**")
                .authorizeRequests()
            .antMatchers("/hystrix.stream")
                .authenticated(); // or whatever you like in here
            // rest of your security config
    }

}