我在Jersey中使用Spring Boot (1.3.0) (pom依赖:spring-boot-starter-jersey,spring-boot-starter-actuator,spring-boot-starter-web,spring-boot-starter-security)。
我有一个Jersey端点(见下文),它非常简单:
@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,执行器终端通过基本身份验证得到了保护。
我这里的问题是/helloworld也是安全的,但我想让它不安全。
我该怎么做呢?
谢谢!
发布于 2016-09-19 19:29:31
您必须在yaml/properties文件中配置如下设置-
server:
port: 8080
context-path: /MyApplication
security:
user:
name: admin
password: secret
basic:
enabled: false
management:
context-path: /actuator
security:
enabled: true因此,对于您的应用程序,安全性是禁用的,但对于执行器端点是启用的。请确保您没有在管理安全的情况下配置用户名/密码,否则将无法工作。
发布于 2016-05-02 08:17:52
您可以将security.user.name属性和management.security.role一起添加到您的配置中,如application.properties或spring cloud config center中的配置,并在启动日志中搜索随机密码。当然,您也可以在bootstrap.yml中添加密码以使用指定的密码。
https://stackoverflow.com/questions/36972549
复制相似问题