我尝试使用spring boot创建一些示例项目,增加了spring的安全性。 成功登录后,我的欢迎页面上总是出现403禁止错误。请在下面检查我的代码
SpringSecurityConfiguration
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception
{
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests().anyRequest().hasAnyRole("ADMIN")
.and()
.authorizeRequests().antMatchers("/events/login**").permitAll()
.and()
.formLogin().loginPage("/events/login").usernameParameter("email").permitAll()
.defaultSuccessUrl("/events/welcome", true);
}