Spring Security - Access is denied (user is not anonymous) spring-security-core-4.0.3.RELEASE

前端 未结 5 856
暗喜
暗喜 2020-12-15 06:58

can anyone see an failure in this Spring Security Config File?

After Login the i get a debug message:

Access is denied (user is not anonymous)

5条回答
  •  长情又很酷
    2020-12-15 07:09

    try below code. it worked for me.

         http
        .csrf().disable()
        .authorizeRequests()
    
        .antMatchers("/login**", "/").permitAll()        
        .antMatchers("/user/**").access("hasAnyAuthority('USER')")
        .antMatchers("/admin/**").access("hasAnyAuthority('ADMIN')")
    
        .anyRequest().fullyAuthenticated()
            .and()
        .formLogin();
    

提交回复
热议问题