php-Symfony2-security.yml中“ anonymous.key”的用途
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php-Symfony2-security.yml中“ anonymous.key”的用途,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2006字,纯文字阅读大概需要3分钟。
内容图文
![php-Symfony2-security.yml中“ anonymous.key”的用途](/upload/InfoBanner/zyjiaocheng/662/eb35404be74544a58c05064dbc9c6aaf.jpg)
我之前设置了一个Symfony2应用程序,该应用程序包括匿名路由和受HTTP BasicAuth限制的路由.使用默认值的基本防火墙配置如下所示:
firewalls:
main:
anonymous: ~
http_basic: ~
除了在Symfony2的SecurityBundle Configuration文档中显示full default configuration之外,我无法找到有关匿名属性选项的信息.
匿名属性似乎只有一个属性:key,如默认配置的第206行所示:
some_firewall_listener:
# ...
anonymous:
key: 4f954a0667e01
我研究了核心代码库,并进行了一些单元测试,它似乎是AnonymousToken和/或AnonymousAuthenticationListener的构造函数值,但到目前为止我还没有学到很多.
Remember_me下也有一个关键属性,但我认为这有不同的用途.
我找不到任何其他信息来描述此特定键属性是什么以及其目的是什么. AnonymousToken :: __ construct()需要$key和$user参数,因此我假设此选项只是对Symfony2否则创建自己的值的手动覆盖.
有人可以建议吗?谢谢 :)
解决方法:
在验证AnonymousToken时,将比较AnonymousAuthenticationProvider的密钥和令牌.当它们不匹配时,身份验证将失败.
这同样适用于RememberMeToken和RememberMeAuthenticationProvider.如果令牌和提供者的密钥不匹配,则身份验证失败.
该密钥用于确定当前正在验证的令牌是由应用程序本身创建的,而不是由恶意客户端提交的.这主要是因为Symfony Security基于Spring Security(Java),而Java具有RMI(远程方法调用)支持.从Spring docs:
The use of the key property should not be regarded as providing any real security here. It is merely a book-keeping exercise. If you are sharing a ProviderManager which contains an AnonymousAuthenticationProvider in a scenario where it is possible for an authenticating client to construct the Authentication object (such as with RMI invocations), then a malicious client could submit an AnonymousAuthenticationToken which it had created itself (with chosen username and authority list). If the key is guessable or can be found out, then the token would be accepted by the anonymous provider. This isn’t a problem with normal usage but if you are using RMI you would be best to use a customized ProviderManager which omits the anonymous provider rather than sharing the one you use for your HTTP authentication mechanisms.
内容总结
以上是互联网集市为您收集整理的php-Symfony2-security.yml中“ anonymous.key”的用途全部内容,希望文章能够帮你解决php-Symfony2-security.yml中“ anonymous.key”的用途所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。