[英]Best way to handle single user authentication?
I'm working on a small app with Symfony 2.5, and I'd like to know what is the best way to handle security, but just for only one user. 我正在使用Symfony 2.5开发一个小型应用程序,我想知道什么是处理安全性的最佳方法,但仅适用于一个用户。 I could do this with an
.htaccess
but maybe their exists some light and quickly installable sf2 bundle which could do the job. 我可以使用
.htaccess
来执行此操作,但也许它们存在一些轻便且可快速安装的sf2捆绑包,可以完成此工作。 I don't want role stuff, or profile, just a way to authenticate myself. 我不希望角色或个人资料只是一种认证自己的方式。
Symfony2 let's you easily use http authentication. Symfony2让您轻松使用http身份验证。 Together with the
in_memory
provider, you have a perfect solution for your use case. 与
in_memory
提供程序一起,您将为您的用例提供完美的解决方案。
security:
firewalls:
secured_area:
pattern: ^/
anonymous: ~
http_basic:
realm: "Secured Demo Area"
access_control:
- { path: ^/admin/, roles: ROLE_ADMIN }
# Include the following line to also secure the /admin path itself
# - { path: ^/admin$, roles: ROLE_ADMIN }
providers:
in_memory:
memory:
users:
ryan: { password: ryanpass, roles: 'ROLE_USER' }
admin: { password: kitten, roles: 'ROLE_ADMIN' }
encoders:
Symfony\Component\Security\Core\User\User: plaintext
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.