当我以admin身份登录时,我从github Link here克隆了这个spring-boot项目并尝试运行它。一切正常。
但是当我登录时以用户身份显示此页面
SecurityConfig.java
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private static final String HBS_ADMIN = "/hbs/**";
private static final String HBS_USER = "/hbs/*";
private static final String ADMIN = "ADMIN";
private static final String USER = "USER";
@Override
public void configure(HttpSecurity httpSecurity) throws Exception{
httpSecurity
.authorizeRequests()
.antMatchers(HBS_ADMIN).hasRole(ADMIN)
.antMatchers(HBS_USER).hasRole(USER)
.and()
.formLogin();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
auth.inMemoryAuthentication()
.withUser("admin").password("password").roles(ADMIN)
.and()
.withUser("user").password("password").roles(USER);
}
}
请帮助我,谢谢。