无法识别的选项" google"在" security.firewalls.secured_area.oauth"

时间:2017-02-12 13:15:51

标签: symfony google-oauth

我正在尝试使用Symfony HWIOAuthBundle

为我的网站实施Google登录

我的问题:

  

无法识别的选项" google"下   " security.firewalls.secured_area.oauth"

我的client_id和client_secret非常好并且收到了Google,我只是因为隐私而没有粘贴它。

使用此HWIOAuthBundle Documentation

hwi_oauth:
    firewall_names: [secured_area]
    resource_owners:
        any_name:
            type:                google
            client_id:           myid
            client_secret:       mysecret
            scope:               "https://www.googleapis.com/auth/plus.login"
            options:
                request_visible_actions: "http://schemas.google.com/AddActivity http://schemas.google.com/CommentActivity"

我的Security.yml文件:

安全性:

# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
    in_memory:
        memory: ~

firewalls:
    # disables authentication for assets and the profiler, adapt it according to your needs

    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false

    #main:
    default:

        anonymous: ~
        http_basic: ~
        # 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:
    # require ROLE_ADMIN for /main*
   # - { path: ^/main, roles: ROLE_ADMIN }

    secured_area:

      anonymous: ~
      oauth:
         resource_owners:

         google:             "/login/check-google"

         login_path:        /login
         use_forward:       false
         failure_path:      /login

         oauth_user_provider:

            service: my.oauth_aware.user_provider.service

access_control:
          - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }

1 个答案:

答案 0 :(得分:1)

在您的security.ym中,google选项应位于resource_owners下,您必须添加一个标签空间,它应该有效。

 resource_owners:
      google:           "/login/check-google"