Spring Boot Security 403错误,如何解决?

时间:2019-09-09 15:15:09

标签: spring spring-boot security

我尝试使用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);
    }

0 个答案:

没有答案