首页 > 其他分享 >Spring Security登录的流程

Spring Security登录的流程

时间:2022-08-19 19:22:06浏览次数:65  
标签:authenticate 登录 Spring authentication user 进入 Security 方法

Spring Security登录的流程

1、UsernamePasswordAuthenticationFilter这过滤器开始

attemptAuthentication方法

请求的request中的参数

setDetails(request, authRequest); 是在设置一些seesion的信息

然后进入这个return this.getAuthenticationManager().authenticate(authRequest);

2、ProviderManager进入这个方法进程验证

authenticate方法

第一次进入因为paoviders的参数不符合,从新再次进入

第二进入的时的参数信息

result = provider.authenticate(authentication);进入

3、AbstractUserDetailsAuthenticationProvider对象

authenticate方法

通过用户名和封装好的对象去查找user(UserDetails)这个对象

user = retrieveUser(username, (UsernamePasswordAuthenticationToken) authentication);

4、DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider

retrieveUser方法

UserDetails loadedUser = this.getUserDetailsService().loadUserByUsername(username);

通过自己写的service层并且实现了UserDetailsService接口的方法中去数据库查询该用户

这里过后就获取到了这个查询的user的信息

然后进入

additionalAuthenticationChecks(user, (UsernamePasswordAuthenticationToken) authentication);

这个方法进行密码的校验检查

additionalAuthenticationChecks方法

ProviderManager 一直到这个里面的 authenticate 方法结束,这中间把密码都移除了,估计未来保证安全

最后的这个返回的 result (第二个进入的返回)

然后接着就是第一次进入的返回了

5、AbstractAuthenticationProcessingFilter

后面就该执行以下登录成功后的处理了,比如权限认证

还有其他过滤器的执行了

标签:authenticate,登录,Spring,authentication,user,进入,Security,方法
From: https://www.cnblogs.com/shuisanya/p/16603115.html

相关文章

  • spring boot thymeleaf 不能访问templates目录下的页面问题
    springboot默认情况下可以直接访问四个目录下的静态文件(https://www.cnblogs.com/realzhaijiayu/p/16566667.html)publicstaticresourcesMETA-INF/resources引入thym......
  • SpringWebflux框架里导出excel文档
    本demo里使用springboot2.7.0版本。@GetMapping("/download/excel/file")publicMono<Void>downloadExcelFile(ServerHttpResponseresponse,WebSessionwebSessi......
  • spring5 ioc 管理bean 注解
    1.注解种类@Component(value="student")@Service@Repository@Controller 2.使用注解扫描包<context:component-scanbase-package="com.cj"></context:componen......
  • 【文件上传】Spring MVC 文件上传
    (1)文件上传三要素:1、表单的提交方式method="POST"2、表单的enctype属性是多部分表单形式enctype=“multipart/form-data"3、表单项(元素)type="file"<formaction=""m......
  • SpringBoot集成Swagger
    一、pom.xml中引入如下依赖:<!--swagger2--><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</arti......
  • SpringCloud学习之注册中心搭建过程中的一些问题
    问题1 解决方案:这个问题需要在application.properties里添加 hostname这项配置,奇葩的是这个地方只能配localhost,配成其他值一样会报上述错误。 ......
  • 解决Spring Boot Configuration Annotation Processor not configured
    解决SpringBootConfigurationAnnotationProcessornotconfigured问题背景进行SpringBoot配置文件部署时,发出警告,该爆红不影响使用,但是爆红感觉很难受,点击OpenDocu......
  • springmvc的简单使用(3)
    一:日期处理:1:日期的提交处理: 单个日期处理:要使用注解,并且注解要搭配springmvc文件中的<annotationdriven><mvc:annotation-driven></mvc:annotation-driven><formact......
  • 【Spring5学习笔记(3)】JdbcTemplate操作数据库:
    JdbcTemplate(概念和准备)1、什么是JdbcTempate(1)Spring框架对JDBC进行封装,使用JdbcTemplate方便实现对数据库操作2、准备工作(1)引入相关依赖(2)在spring配置文件配......
  • mysql数据库修改登录密码策略
    showvariableslike'validate_password%';  查看登录密码策略默认策略  1、查看mysql初始的密码策略,    输入语句“SHOWVARIABLESLIKE'validate_p......