spring security权限认证原理图
2019-07-02 11:12:15   5  举报             
     
         
 SpringSecurity权限认证流程图
    作者其他创作
 大纲/内容
 重写该方法
    result
  String username = obtainUsername(request);       String password = obtainPassword(request);
  return this.getAuthenticationManager().authenticate(authRequest);
  实际调用(子类实现)
  实现
  public Authentication attemptAuthentication(span style=\"font-size: inherit;\
  传入调用
  执行由子类重写后的方法
  调用
  交由AuthenticationManager接口的ProviderManager实现类处理
   // 拿到全部的providerIterator e = this.getProviders().iterator();        // 遍历provider        while(e.hasNext()) {
  usernamepassword
  authRequest
  调用createSuccessAuthentication方法进行授权成功
   return loadedUser;
  return   UsernamePasswordAuthenticationToken result
  ProviderManager.authenticate(Authentication authentication);
  // 找到后直接break,并由当前provider来进行校验工作result = provider.authenticate(authentication);
   //检查由DefaultPreAuthenticationChecks类实现(主要判断当前用户是否锁定,过期,冻结* User接口)  this.preAuthenticationChecks.check(user);// 检测用户密码是否过期      this.postAuthenticationChecks.check(user);
  AbstractUserDetailsAuthenticationProvider
  public Authentication authenticate(Authentication authentication)
  UsernamePasswordAuthenticationFilter
   public Authentication authenticate(Authentication authentication) 
  UsernamePasswordAuthenticationFilter 
  Authentication
  调用AuthenticationManager的authenticate方法进行验证
  request
  request首先进入的第一个拦截器
  return result;
  AuthenticationProvider
  return user
  DaoAuthenticationProvider
  这里交由AuthenticationProvider接口的实现类DaoAuthenticationProvider来处理。
  继承
  AuthenticationManager
   loadedUser = this.getUserDetailsService().loadUserByUsername(username);
  authRequest是一个authentication
  AbstractAuthenticationProcessingFilter
  public class MyUserDetailsService implements UserDetailsService
   public UserDetails loadUserByUsername(String username)
  authResult
  // 挨着个的校验是否支持当前token            if(provider.supports(toTest))
    
    收藏 
     
 
 
 
 
  0 条评论
 下一页
  
   
  
  
  
  
  
  
  
  
 