Spring 弹簧护套和弹簧执行器-禁用安全性
我在我的应用程序中使用spring boot 1.3.1和spring boot执行器。我在Spring 弹簧护套和弹簧执行器-禁用安全性,spring,spring-security,spring-boot,spring-boot-actuator,Spring,Spring Security,Spring Boot,Spring Boot Actuator,我在我的应用程序中使用spring boot 1.3.1和spring boot执行器。我在pom.xml中使用springbootstarter父级作为父级 security: basic: enabled: false management: security: enabled: false 为了禁用安全性,我在我的应用程序.yml中添加了两个条目 security: basic: enabled: false management: securit
pom.xml
中使用springbootstarter父级
作为父级
security:
basic:
enabled: false
management:
security:
enabled: false
为了禁用安全性,我在我的应用程序.yml
中添加了两个条目
security:
basic:
enabled: false
management:
security:
enabled: false
它仍然没有禁用基本安全性。在本地tomcat中启动应用程序时,我在日志文件中看到了默认密码。基本安全性已禁用但Spring Boot即使在将
security.Basic.enabled
设置为false
后,也会将身份验证管理器配置为默认用户/pass。但是基本的安全被禁用。您可以重新配置authenticationManager以覆盖此行为,如下所示:
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
@Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("me").password("secret").roles("ADMIN");
}
}
通过在应用程序中设置用户名/密码,可以停止spring引导以记录默认密码。yml-
security:
basic:
enabled: false
user:
name: user
password: ****
如果存在Spring安全性,则需要添加一个自定义安全配置,以允许对端点进行未经验证的访问。比如:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
//....
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers(HttpMethod.GET, "/actuator/**");
super.configure(web);
}
}