SpringSecurity Authentication

Authentication是用户认证的信息,会提供给AuthenticationManager,所以刚创建时要设置他的isAuthenticated()返回false

1)principal 对应 UserDetail
2)credentials 对应 password
3)authoritis 对应 GrantedAuthority

参考:
https://docs.spring.io/spring-security/site/docs/5.4.5/reference/html5/#servlet-authentication-authentication

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Spring Security AuthenticationSpring Security 框架中的一个关键概念。它提供了身份验证(Authentication)的功能,用于验证用户的身份和凭据。 在 Spring Security 中,身份验证是通过 AuthenticationManager 进行的。AuthenticationManager 是一个接口,定义了身份验证的方法。它通常由 ProviderManager 实现,ProviderManager 可以配置多个 AuthenticationProvider,每个 Provider 都负责特定类型的身份验证。 在进行身份验证时,用户提供的凭据将被封装为一个 Authentication 对象,并传递给 AuthenticationManager 进行验证。AuthenticationManager 将根据配置的 AuthenticationProvider 逐个尝试进行验证,直到找到一个能够成功验证该凭据的 Provider。如果所有 Provider 都无法验证凭据,将抛出相应的异常。 一旦成功验证了用户的凭据,AuthenticationManager 将返回一个经过填充的 Authentication 对象,其中包含有关用户身份的信息和权限。这个经过验证的 Authentication 对象将被存储在 SecurityContext 中,以供后续的授权(Authorization)过程使用。 在 Spring Security 中,我们可以使用不同的凭据进行身份验证,比如用户名/密码、基于令牌的身份验证等。同时,Spring Security 还提供了灵活的配置选项,可以根据需求自定义身份验证的流程和规则。 希望以上内容对你有所帮助!如果还有其他问题,请继续提问。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值