| 
 
 SecurityConfig 配置类  
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
   
   @Override
   protected void configure(HttpSecurity http) throws Exception {
       http.authorizeRequests().antMatchers("/").permitAll()
      .antMatchers("/level1/**").hasRole("vip1")
      .antMatchers("/level2/**").hasRole("vip2")
      .antMatchers("/level3/**").hasRole("vip3");
       
           
           
       http.formLogin()
          .usernameParameter("username")
          .passwordParameter("password")
          .loginPage("/toLogin")
          .loginProcessingUrl("/login"); 
       
           
           
       http.csrf().disable();
       http.logout().logoutSuccessUrl("/");
       
       http.rememberMe().rememberMeParameter("remember");
  }
   
   @Override
   protected void configure(AuthenticationManagerBuilder auth) throws Exception {
       
       
       
       
       auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder())
              .withUser("kuangshen").password(new BCryptPasswordEncoder().encode("123456")).roles("vip2","vip3")
              .and()
              .withUser("root").password(new BCryptPasswordEncoder().encode("123456")).roles("vip1","vip2","vip3")
              .and()
              .withUser("guest").password(new BCryptPasswordEncoder().encode("123456")).roles("vip1","vip2");
  }
}
  
参考目录 
非常详细的 笔记  https://blog.csdn.net/weixin_44449838/article/details/108676864  
官网 对于 SpringSecurity 相关的 配置  https://docs.spring.io/spring-security/site/docs/current/reference/html5/#hello-web-security-java-configuration  
B站狂神  https://www.bilibili.com/video/BV1PE411i7CV?p=35  
狂神 集成SpringSecurity  https://mp.weixin.qq.com/s?__biz=Mzg2NTAzMTExNg==&mid=2247483957&idx=1&sn=fc30511490b160cd1519e7a7ee3d4ed0&scene=19#wechat_redirect 
                
                
                
        
    
 
 |