首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >捆绑FOSOAuthServerBundle设置错误

捆绑FOSOAuthServerBundle设置错误
EN

Stack Overflow用户
提问于 2016-11-22 10:48:12
回答 1查看 920关注 0票数 1

我已经安装了FOSOauthServerBundle,但是csrf_provider的配置似乎有问题,我不知道如何解决它,因为我在执行composer更新时从https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/master/Resources/doc/index.md复制了代码--我有这个错误。

代码语言:javascript
复制
[RuntimeException]
      An error occurred when executing the ""cache:clear --no-warmup"" command:
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationExcept
      ion] Unrecognized option "csrf_provider" under "security.firewalls.main.form_login"

当我去本地主机时,我得到了这个致命的错误。

代码语言:javascript
复制
Fatal error: Uncaught Symfony\Component\Config\Definition\Exception\InvalidConfigurationException: Unrecognized option "csrf_provider" under "security.firewalls.main.form_login" in C:\wamp64\www\MDSAP\mdsap-api\vendor\symfony\symfony\src\Symfony\Component\Config\Definition\ArrayNode.php on line 317
    ( ! ) Symfony\Component\Config\Definition\Exception\InvalidConfigurationException: Unrecognized option "csrf_provider" under "security.firewalls.main.form_login" in C:\wamp64\www\MDSAP\mdsap-api\vendor\symfony\symfony\src\Symfony\Component\Config\Definition\ArrayNode.php on line 317

我是security.yml

代码语言:javascript
复制
# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:

    encoders:
        FOS\UserBundle\Model\UserInterface: sha1

    role_hierarchy:
        ROLE_ADHERANT:    ROLE_USER
        ROLE_STAGIAIRE:   ROLE_USER
        ROLE_PARTENAIRE:  ROLE_USER
        ROLE_DUPPLESSIX:  ROLE_USER
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN
    # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    firewalls:
        oauth_token:
            pattern:    ^/oauth/v2/token
            security:   false

        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
            logout:       true
            anonymous:    true
            # Add your favorite authentication process here

        api:
            pattern:    ^/api
            fos_oauth:  true
            stateless:  true
            anonymous:  false # can be omitted as its default value

        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false

        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_token_generator: security.csrf.token_manager
                # if you are using Symfony < 2.8, use the following config instead:
                # csrf_provider: form.csrf_provider

            logout:       true
            anonymous:    true
            # activate different ways to authenticate

            # http_basic: ~
            # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate

            # form_login: ~
            # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }
        - { path: ^/api, roles: [ IS_AUTHENTICATED_FULLY ] }
EN

回答 1

Stack Overflow用户

发布于 2016-11-22 11:07:17

不确定,但您需要做的就是在更新composer之前启用csrf protaction。

config.yml

代码语言:javascript
复制
framework:
    csrf_protection:
        enabled: true
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40739853

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档