zoukankan      html  css  js  c++  java
  • Spring Security 安全验证

    摘自:https://www.cnblogs.com/shiyu404/p/6530894.html

    这篇文章是对Spring Security的Authentication模块进行一个初步的概念了解,知道它是如何进行用户认证的

    考虑一个大家比较熟悉的标准认证过程:

    1.用户使用username和password登录

    2.系统验证这个password对于该username是正确的

    3.假设第二步验证成功,获取该用户的上下文信息(如他的角色列表)

    4.围绕该用户建立安全上下文(security context)

    5.用户可能继续进行的一些操作被一个验证控制机制潜在的管理,这个验证机制会根据当前用户的安全上下文来验证权限。

    认证过程就是又前三项构成的。在Spring Security中是这样处理这三部分的:

    1.username和password被获得后封装到一个UsernamePasswordAuthenticationToken(Authentication接口的实例)的实例中

    2.这个token被传递给AuthenticationManager进行验证

    3.成功认证后AuthenticationManager将返回一个得到完整填充的Authentication实例

    4.通过调用SecurityContextHolder.getContext().setAuthentication(...),参数传递authentication对象,来建立安全上下文(security context)

  • 相关阅读:
    Code Forces Gym 100886J Sockets(二分)
    CSU 1092 Barricade
    CodeChef Mahesh and his lost array
    CodeChef Gcd Queries
    CodeChef GCD2
    CodeChef Sereja and LCM(矩阵快速幂)
    CodeChef Sereja and GCD
    CodeChef Little Elephant and Balance
    CodeChef Count Substrings
    hdu 4001 To Miss Our Children Time( sort + DP )
  • 原文地址:https://www.cnblogs.com/rdchen/p/10690961.html
Copyright © 2011-2022 走看看