isAuthenticated 和 isFullyAuthenticated 之间的区别
Posted
技术标签:
【中文标题】isAuthenticated 和 isFullyAuthenticated 之间的区别【英文标题】:Difference between isAuthenticated and isFullyAuthenticated 【发布时间】:2015-09-06 07:52:17 【问题描述】:我正在尝试学习 Spring Security,但我有疑问: Spring Security 中的 isAuthenticated 和 isFullyAuthenticated 有什么区别
【问题讨论】:
【参考方案1】:来自 spring-security 文档:
isAuthenticated() Returns true if the user is not anonymous
isFullyAuthenticated() Returns true if the user is not an anonymous or a remember-me user
【讨论】:
所以如果我不记得我的功能,有没有区别? 更正没有其他区别,您只需使用 isAuthenticated() 代替。【参考方案2】:实际上,我认为他们在AuthenticatedVoter 文档中解释得更好:
将检查当前的
Authentication
以确定主体是否具有特定级别的身份验证。“FULLY”认证选项表示用户已完全认证 (即 AuthenticationTrustResolver.isAnonymous(Authentication) 是 false 而AuthenticationTrustResolver.isRememberMe(Authentication) 是false。
“REMEMBERED”将授予访问权限,如果委托人是 通过 remember-me 认证或完全认证。这 如果委托人通过身份验证,“匿名”将授予访问权限 记住我,或匿名,或通过完全身份验证。
他们在this table of their docs 中提到:
,则返回 true
isAuthenticated()
- 如果用户非匿名
isFullyAuthenticated()
- 如果用户不是匿名的 或 记住我的用户,则返回 true
【讨论】:
以上是关于isAuthenticated 和 isFullyAuthenticated 之间的区别的主要内容,如果未能解决你的问题,请参考以下文章
isAnonymous() 和 isAuthenticated() 都返回 false
为啥我在使用 Passport 和会话时没有保持登录状态? Passport 的“isAuthenticated()”总是返回 false
spring security 3.1 isAuthenticated() 不工作