我正在设置一个Spring Boot 1.3安全应用程序,但带有一个对公众不可见的管理端口,因此我不需要在该端口上进行任何安全控制。
这就是我想要实现的简单目标:
但是一旦我添加WebSecurityConfigurerAdapter,它就会自动对两个端口生效。如果管理端口不同,设置“management.security.enabled=false”没有效果,这是一个bug吗?我怎样才能只为管理端口禁用安全性呢?
我的简单安全配置:
这就是我想要实现的简单目标:
server.port = 8080 # -> secure
management.port = 8081 # -> unsecure
但是一旦我添加WebSecurityConfigurerAdapter,它就会自动对两个端口生效。如果管理端口不同,设置“management.security.enabled=false”没有效果,这是一个bug吗?我怎样才能只为管理端口禁用安全性呢?
我的简单安全配置:
@Configuration
@EnableWebSecurity
static class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated();
}
}
我知道一个可能的解决方法是设置自定义上下文路径,例如/manage
,并忽略此路径的安全性,但使用非标准路径似乎不是理想的选择,而且在安全配置中解析路径时需要进行调整而不是硬编码,因此我想找到是否有一种标准方法来解决这个问题。