代码之家  ›  专栏  ›  技术社区  ›  indybee

如何仅针对/执行器/健康禁用安全?

  •  0
  • indybee  · 技术社区  · 4 年前

    我的春季启动应用程序已启用安全功能。

    如何访问 /actuator/health 没有身份验证?

    有一个 WebSecurityConfigurerAdapter 在应用程序中。

    我发现 an example 使用:

    public void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/health").permitAll().anyRequest().authenticated();
    
    }
    

    和 another example 使用:

    public void configure(WebSecurity web) throws Exception {
        web.ignoring()
                .antMatchers("/actuator/health");
    }
    

    每种方法的优缺点是什么?它将用于健康检查。

    0 回复  |  直到 4 年前
        1
  •  3
  •   Toerktumlare    4 年前

    第一个示例仍将包括CORS等安全功能和不同的基本安全标头。您只排除了spring security不会要求身份验证。

    而第二个示例将忽略与spring安全性有关的所有内容,并且请求将不会通过spring安全性的任何基本安全过滤器。

    备选方案总是更好。

    在这里,您可以阅读默认情况下从spring security获得的常见安全保护

    Protection Against Exploits

    推荐文章