【问题标题】:Spring Boot - How to secured the dashboards like Hystrix for admin usersSpring Boot - 如何为管理员用户保护 Hystrix 等仪表板
【发布时间】:2017-03-06 18:57:37
【问题描述】:

我有 Spring Boot REST 服务,其中已经存在基本身份验证。我将 Hystrix 集成到短路外部服务和一个仪表板来监控它。但是如何保护管理员用户的 Hystrix 仪表板?

谢谢, 阿伦。

【问题讨论】:

    标签: spring-boot hystrix


    【解决方案1】:

    配置 Spring Security 以在 /hystrix 端点上强制执行基本身份验证。例如:

    @Configuration
    public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    
        @Override
        protected void configure(final HttpSecurity http) throws Exception {
            http.httpBasic()
                .and()
                .authorizeRequests()
                .antMatchers("/hystrix")
                .authenticated();    
        }
    }
    

    【讨论】:

    • 我已经添加了这个。当我提供凭据时,它与 url localhost:8080/hystrix 一起使用。但是,一旦我输入“/hystrix.stream”并点击“监视器”,它也会进行身份验证。基本上,它对刷新时仪表板屏幕内发出的所有请求(AJAX 调用)进行身份验证,而我无法提供凭据。我的服务是无状态的。
    • 这仅验证“/hystrix”。如果您像这样配置安全性,则流端点不需要身份验证。
    • 它不适用于以下安全配置。 .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
    猜你喜欢
    • 2017-02-06
    • 2016-01-18
    • 2018-05-08
    • 2018-12-12
    • 2020-03-07
    • 2017-04-29
    • 1970-01-01
    • 1970-01-01
    • 2020-07-17
    相关资源
    最近更新 更多