【发布时间】:2015-12-15 13:17:24
【问题描述】:
我正在设置一个 Spring Boot 1.3 安全应用程序,但有一个公众无法访问的管理端口,因此我不需要在此端口上进行任何安全保护。
这正是我想要实现的目标:
server.port = 8080 # -> secure
management.port = 8081 # -> unsecure
但只要我添加了 WebSecurityConfigurerAdapter,它就会自动对两个端口生效。如果管理端口不同,设置management.security.enabled=false 无效,这是一个错误吗?我如何才能仅禁用管理端口的安全性?
我的简单安全配置:
@Configuration
@EnableWebSecurity
static class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated();
}
}
我知道可能的解决方法是设置自定义上下文路径,例如。 /manage 并从安全性中忽略此路径,但是使用非标准路径加上摆弄以将路径解析到安全配置中而不对其进行硬编码似乎并不理想,所以我想知道是否有一个标准的方法。
【问题讨论】:
标签: java spring-security spring-boot