【发布时间】:2015-08-25 23:53:18
【问题描述】:
我在 Spring Boot 的应用程序中添加了一个自定义安全配置,但是关于“使用默认安全密码”的消息仍然存在于 LOG 文件中。
有什么可以删除的吗?我不需要这个默认密码。 Spring Boot 似乎无法识别我的安全策略。
@Configuration
@EnableWebSecurity
public class CustomSecurityConfig extends WebSecurityConfigurerAdapter {
private final String uri = "/custom/*";
@Override
public void configure(final HttpSecurity http) throws Exception {
http.csrf().disable();
http.headers().httpStrictTransportSecurity().disable();
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
// Authorize sub-folders permissions
http.antMatcher(uri).authorizeRequests().anyRequest().permitAll();
}
}
【问题讨论】:
-
这个类是否在正确的包中,因此可以找到?几个月前我犯了这个错误......将密码设置为已知值是否足够(我假设不是......)?
-
也许你有和我一样的问题。我很幸运,Syer 先生给了我答案;-) stackoverflow.com/questions/27981681/…
-
还有另一个配置类导入此安全配置@Import({ CustomSecurityConfig .class })。这个类由 Spring Boot 扫描,我在另一个与 CAS 安全相关的案例中注意到,Spring Boot 仅在我执行 @Inject public void configureGlobal(final AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { 时删除了此消息
-
我尝试添加 security.basic.enabled=false 并没有任何改变。
-
正确答案是:错误的包装。当您复制文件夹并粘贴到您的项目时会出现此错误。您可以将文件夹重构为正确的包并完成。
标签: java spring spring-boot spring-security