HWIOAuthBundle `发生身份验证异常`

HWIOAuthBundle `An authentication exception occurred`

我对 HWIOAuthBundleFOSUserBundle 集成有问题。)

点击link /connect/google,出现这个画面。 (屏幕模糊,因为是客户的邮件)

然后返回回调URL/login/check-google

它重定向到 /login 并显示此消息

An authentication exception occurred.

如果我直接输入 /login/check-google,什么也不会发生,只是重定向到 login

我不知道 /login/check-google 页面上有什么问题。

如何查看??? (我在这个问题上卡了一个星期,我温习更新了文章。)

我的环境是

security.yml

security:
    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username_email

    firewalls:
        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
            oauth:
                resource_owners:
                    google:             "/login/check-google"
                login_path:        /login
                use_forward:       false
                failure_path:      /login
                oauth_user_provider:
                    service: my_user_provider
        login:
            pattern:  ^/login$
            security: false

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

config.yml

hwi_oauth:
    connect:
        account_connector: my_user_provider
    firewall_names: [main]
    fosub:
        username_iterations: 30
        properties:
            google: google_id
    resource_owners:
        google:
            type:                google
            client_id:           XXXXXXXX
            client_secret:       XXXXXXXXXX
            scope:               "email profile"

service.xml

    <parameters>
     <parameter key="my_user_provider.class">Acme\UserBundle\Security\Core\User\FOSUBUserProvider</parameter>
    </parameters>
    <services>
          <service id="my_user_provider" class="%my_user_provider.class%">
            <argument type="service" id="fos_user.user_manager"/>
            <argument type="service" id="service_container" />

            <argument type="collection">
                <argument key="google">google_id</argument>       
            </argument>   
        </service>
    </services>

routing.yml

admin_area:
    resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
    prefix: /admin

_sonata_admin:
    resource: .
    type: sonata_admin
    prefix: /admin

acme_member:
    resource: "@AcmeMemberBundle/Resources/config/routing.yml"
    prefix:   /member

_user_bundle:
    resource: "@UserBundle/Resources/config/routing.yml"

acme_top:
    resource: "@AcmeTopBundle/Resources/config/routing.yml"
    prefix:   /

fos_user_group:
    resource: "@FOSUserBundle/Resources/config/routing/group.xml"
    prefix: /group


sonata_page_cache:
    resource: '@SonataCacheBundle/Resources/config/routing/cache.xml'
    prefix: /

#HWIOAuthBundle routes
hwi_oauth_security:
    resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
    prefix: /login

hwi_oauth_connect:
    resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
    prefix: /connect

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

facebook_login:
    path: /login/check-facebook

google_login:
    path: /login/check-google


fos_js_routing:
  resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"

我解决了我的问题。

降级 >>> HWIAuthBundle 0.4.3

并将其添加到 config.yml

hwi_oauth:
    http_client:
        verify_peer: false

这是因为 https / http 的不同。 Google 请求 https。 但是它会跳过 https 验证。

还要检查最后一条评论。

https://github.com/hwi/HWIOAuthBundle/issues/1024

我不知道 hwi/oauth-bundle 自上次回答以来是否发生了变化,但现在不需要降级软件包。

确实在 0.6.x 版本中删除了 http_client 选项,因为内部 Http 客户端已替换为 HttplugBundle。

现在禁用“verify_peer”选项的正确方法在此处的官方文档中有描述:https://github.com/hwi/HWIOAuthBundle/blob/master/Resources/doc/internals/configuring_the_http_client.md