SpringSecurity设置登录的三个方式

SpringSecurity设置登录的三个方式(基于SpringBoot)

  SpringSecurity Web 权限方案

  1.通过配置文件

    在SpringSecurity接管后会默认使用它的用户名和每次启动随机加密的密码

    

  2.通过配置类

 

    定义一个config的配置类,加上@Configuration 表示为配置类,继承 WebSecurityConfigurerAdapter  实现configure(AuthenticationManagerBuilder auth)这个方法

    

 

 

  3.自定义编写实现类

    1.创建配置类,设置哪个userDetailsService实现类

    

 

     2.编写实现类,返回User对象,User对象有用户名密码还有操作权限

      实现UserDetailsService接口,实现loadUserByUsername方法

      

       下边是从数据库查询的用户校验(本方式使用Mybatisplus进行查询数据),记得在启动类添加扫描@MapperScan(value = "xxx.com.securitydemo01")

      

 

posted @ 2021-04-13 21:52  UsualMind  阅读(1103)  评论(0)    收藏  举报