【发布时间】:2018-09-07 15:55:17
【问题描述】:
为什么以下基本安全配置不适用于 inMemoryAuthentication() 子句?
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.httpBasic()
.and()
.authorizeRequests()
.anyRequest().authenticated();
super.configure(http);
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("username").password("password");
super.configure(auth);
}
}
应用初始化后,仍然只有Spring自己生成的默认user,没有username这样的用户。
【问题讨论】:
标签: java spring spring-boot spring-security