目前我的项目运行良好。我使用 FOSUserBundle 来管理我的用户。现在,我想实现 OAuth,所以我使用 FOSOAuthServerBundle。大多数开发人员推荐使用此捆绑包来实现 OAuth。
我遵循了 FOSOAuthServerBundle 的文档。通常,我必须在我的 security.yml 中添加更多信息,但我不确切知道我必须做什么......
这是我的 security.yml :
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
Moodress\Bundle\UserBundle\Entity\User: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
main:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
oauth_token:
pattern: ^/oauth/v2/token
security: false
oauth_authorize:
pattern: ^/oauth/v2/auth
main:
pattern: ^/
fos_oauth: true
stateless: true
anonymous: true
我想可能有一些信息要添加到防火墙中??
我真的不知道如何使 FOSOAuthServerBundle 与 FOSUserBundle 一起工作。之前,仅使用 FOSUserBundle,我使用了 FOSUserBundle 的登录表单和登录检查。现在我把 FOSOAuthServerBundle 的所有基本配置都放好了,接下来我要做什么呢?我应该使用哪种形式?哪个登录检查?令牌是由 FOSOAuthServerBundle 自动创建的?在文档中,他们展示了如何创建客户端......我应该在我的项目中添加这个代码吗?如果是...在哪里?:/
我在网上找到了这篇文章:http: //blog.logicexception.com/2012/04/securing-syfmony2-rest-service-wiith.html
我试图实现这一点,但我不敢相信我们需要添加所有这些文件才能使其工作......
如果有人知道如何使用 FOSUserBundle 制作 FOSOAuthServerBundle,那将非常有帮助。