FOSOAuthServerBundle - 必须配置路径“security”处的子节点“providers”

时间:2014-12-02 13:08:17

标签: php symfony fosoauthserverbundle

我正在尝试实现FOSOAuthServerBundle。我需要它来创建一个集中的身份验证功能,将由其他一些项目共享。

我从这里开始遵循教程:Getting Started With FOSOAuthServerBundle

但我现在遇到问题:当尝试访问路由auth.local / app_dev.php / oauth / v2 / auth时,我收到以下错误:

InvalidConfigurationException: The child node "providers" at path "security" must be configured.

这是我的security.yml:

security:
firewalls:
    api:
        pattern: /api
        fos_oauth: true
        stateless: true
    oauth_authorize:
        pattern: /oauth/v2/auth 
        form_login:
            provider: fos_userbundle
            check_path: /oauth/v2/auth_login_check
            login_path: /oauth/v2/auth_login
        anonymous: true
    oauth_token:
        pattern: /oauth/v2/token
        security: false      

access_control:
    - { path: ^/oauth/v2/auth_login$, role: IS_AUTHENTICATED_ANONYMOUSLY }

1 个答案:

答案 0 :(得分:2)

此错误与FOSOAuthServerBundle无关,而是与security.yml配置有关。您尚未指定提供程序,因此symfony不知道从哪里加载用户。您应该阅读Symfony文档中的the security page以了解如何正确配置它。如果您想要数据库中的用户,请查看loading users from a database。无论哪种方式,你应该有一个security.yml,其结构如下:

security:
    encoders: #your encoder here
    providers: #your provider here
    firewalls: #your firewalls here
    access_control: #your access_control here

您可以通过查看文档并使用最适合您需求的内容来填写每个部分,有很多选项。但您必须拥有providers部分。