弹簧启动 - 仅安全的执行器端点

时间:2016-05-01 22:10:21

标签: security spring-boot spring-boot-actuator

我在Jersey上使用Spring Boot(1.3.0)(pom依赖项:spring-boot-starter-jerseyspring-boot-starter-actuatorspring-boot-starter-webspring-boot-starter-security)。< / p>

我有一个泽西终点(见下文),这非常简单:

@Component
@Path("/helloworld")
public class HelloWorldResource {

    @GET
    public String home() {
        return "Hello World !";
    }
}

我通过设置Spring MVC url(server.servlet-path=/system)的特定路径启用了Spring Boot Actuator,如Spring Boot guide中所述。
感谢spring-boot-starter-security,Actuator端点通过基本身份验证得到保护。

我的问题是/helloworld也是安全的,但我想让它不安全。

我该怎么做?

谢谢!

2 个答案:

答案 0 :(得分:5)

您必须在yaml / properties文件中配置设置,如下所示 -

server:
  port: 8080
  context-path: /MyApplication

security:
   user:
       name: admin
       password: secret
   basic:
       enabled: false

management:
   context-path: /actuator
   security:
             enabled: true

因此,对于您的应用程序,安全性已禁用,但已为执行器端点启用。确保您没有在管理安全性下配置用户名/密码,否则它将无效。

答案 1 :(得分:0)

您可以将$("#gifttwo").on('click', function() { setInterval(function() { $("#shuriken").removeClass("animated wobble").addClass("animated wobble"); }, 3000); }); 属性与security.user.name一起添加到您的配置中,例如management.security.role或配置来自spring cloud配置中心,并在启动日志中搜索随机密码。当然,您也可以在application.properties中添加密码以使用您指定的内容。

相关问题