Spring Security:ROLE_ANONYMOUS 和 IS_AUTHENTICATED_ANONYMOUSLY 之间的区别

发布于 2024-10-27 21:01:27 字数 132 浏览 1 评论 0原文

在 Spring Security 中 ROLE_ANONYMOUS 和 IS_AUTHENTICATED_ANONYMOUSLY 之间有什么区别。

换句话说,RoleVoter 和 AuthenticatedVoter 有什么不同?

In Spring Security What's difference between ROLE_ANONYMOUS and IS_AUTHENTICATED_ANONYMOUSLY .

In other words , how are RoleVoter and AuthenticatedVoter different ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见终念 2024-11-03 21:01:27

spring安全文档,

你会经常看到ROLE_ANONYMOUS
上面拦截器中的属性
配置替换为
IS_AUTHENTICATED_ANONYMOUSLY,即
实际上是同样的事情
定义访问控制。这是一个
使用示例
我们将看到AuthenticatedVoter
在授权章节中。它使用
一个 AuthenticationTrustResolver
处理这个特定的配置
属性并授予访问权限
匿名用户。这
AuthenticatedVoter 方法更多
功能强大,因为它可以让您
区分匿名、
记住我并经过完全身份验证
用户。如果你不需要这个
不过功能,那么你可以
坚持使用 ROLE_ANONYMOUS,这将
由 Spring Security 处理
标准角色投票者。

另外,来自卢克对相关jira 问题

匿名访问问题部分是由于
历史的。匿名代币是
最初引入(即
ROLE_ANONYMOUS)这将允许你
使用“默认安全”
具有特定配置
例外情况。在稍后阶段
AuthenticatedVoter 被引入
让您能够区分
不同级别的身份验证 -
匿名,记住我和
完全验证(即登录
在当前会话期间)。我已经
为匿名添加了额外的位
章解释它们是
一样,除非你需要额外的
提供的功能
经过身份验证的选民。

From the relevant section in spring security documentation,

You will often see the ROLE_ANONYMOUS
attribute in the above interceptor
configuration replaced with
IS_AUTHENTICATED_ANONYMOUSLY, which is
effectively the same thing when
defining access controls. This is an
example of the use of the
AuthenticatedVoter which we will see
in the authorization chapter. It uses
an AuthenticationTrustResolver to
process this particular configuration
attribute and grant access to
anonymous users. The
AuthenticatedVoter approach is more
powerful, since it allows you to
differentiate between anonymous,
remember-me and fully-authenticated
users. If you don't need this
functionality though, then you can
stick with ROLE_ANONYMOUS, which will
be processed by Spring Security's
standard RoleVoter.

Also, from Luke's comment on the related jira issue,

The anonymous access issue is partly
historical. Anonymous tokens were
introduced initially (i.e.
ROLE_ANONYMOUS) which would allow you
to use a "secure-by-defaul"
configurations with specific
exceptions. At a later stage the
AuthenticatedVoter was introduced to
allow you to differentiate between
different levels of authentication -
anonyous, remember-me and
fully-authenticated (i.e. logged in
during the current session). I've
added an extra bit to the anonymous
chapter to explain that they are the
same unless you require the extra
functionality offered by the
AuthenticatedVoter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文