【发布时间】:2017-10-13 21:32:09
【问题描述】:
我在@RestController 端点上使用spring-boot-security 进行基本身份验证,如下所示:
pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
application.properties:
security.user.name=user
security.user.password=pass
问题:如何在开发中禁用基本身份验证,并且仅在使用启动参数-Dspring.profiles.active=production 激活特定配置文件时启用它。
我想将上面的属性移动到application-production.properties。在 dev 中,端点上不应该有任何身份验证。
【问题讨论】:
-
从安全角度来看,反之亦然。始终为开发配置文件启用安全性并禁用...(您不想在生产中意外运行不安全!)。只需添加一个
application-dev.properties即可禁用security.basic.enabled=false的安全性。 -
@M.Deinum 太好了,你能把它添加为答案,以便我接受吗?这就是我一直在寻找的,无需添加任何代码。
标签: java spring spring-boot spring-security