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)

  • 相关阅读:
    MySQL必知必会(数据分组,Group by和Having子句, Select子句的顺序)
    MySQL必知必会(汇总数据, 聚集函数)
    MySQL必知必会(使用函数处理数据)
    菜根谭#206
    菜根谭#205
    菜根谭#204
    菜根谭#203
    菜根谭#202
    菜根谭#201
    菜根谭#200
  • 原文地址:https://www.cnblogs.com/rdchen/p/10690961.html
Copyright © 2011-2022 走看看