hwioauthbundle为谷歌配置

时间:2016-01-12 12:31:55

标签: symfony hwioauthbundle

我尝试使用google api配置此捆绑包进行身份验证。我在google中看到文档和搜索,但仍然无法配置。

现在我有这个错误:

The service "hwi_oauth.security.oauth_utils" has a dependency on a non-existent service "hwi_oauth.resource_ownermap.main".

现在我只想在谷歌的默认页面链接中显示,当我点击它时,我想从谷歌获得响应并在var转储中显示它。

routing.yml:

hwi_oauth_redirect:
    resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
    prefix:   /login

hwi_oauth_login:
    resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
    prefix:   /login

google_login:
    path: /login/check-google

config.yml

hwi_oauth:
    connect:
        account_connector: defaultbundle.oauth_provider
    firewall_names: [secured_area]

    resource_owners:
        google:
            type:                google
            client_id:           ****
            client_secret:       ****
            scope:               "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"

security.yml

    secured_area:
        pattern: ^/
        anonymous: ~
        oauth:
            resource_owners:
                google:             "/login/check-google"
            login_path:        /login
            use_forward:       false
            failure_path:      /login

            oauth_provider:
                service: defaultbundle.oauth_provider
        logout:       true
        anonymous:    true
#        access_control:
#            - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }

services.yml

    defaultbundle.oauth_provider:
    class: Public\defaultBundle\Auth\OAuthProvider
    arguments: [@doctrine]

base.html文件

 <a href="{{ path('hwi_oauth_service_redirect', {'service': 'google' }) }}">
                                <span>Google</span>
                            </a>

OAuthProvider.php

    use HWI\Bundle\OAuthBundle\Security\Core\User\OAuthUserProvider;
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
use HWI\Bundle\OAuthBundle\Security\Core\User\OAuthAwareUserProviderInterface;

class OAuthProvider extends OAuthUserProvider
{



}

1 个答案:

答案 0 :(得分:1)

config.yml(当前:main)中hwi_oauth配置中的防火墙名称错误。 它必须与使用ouath的security.yml(当前:secured_area)中的防火墙名称匹配。

hwi_ouath:
    connect:
        account_connector: defaultbundle.oauth_provider
    firewall_name: secured_area # <---- here is the change (if using 0.3)
    firewall_names: [secured_area] # <--- if using 0.4
    ...

文档: