2013-10-29 42 views
1

即時通訊使用SonataAdminBundle開發與Symfony2我的應用程序。對於用戶登錄im試圖添加谷歌身份驗證。我將HWIOAuthBundle配置爲他們的文檔。一切順利配置和運行。此前谷歌認證的提示,它重定向到以下網址Symfony2.1 - 嘗試添加谷歌身份驗證與HWIOAuthBundle

http://mydomain.com/login/check-google?code=4/i38GBohe0J5q8PLQPdDjOvqVc_EC.4udVR17DB98cOl05ti8ZT3a9L-sEhAI 

這個URL,沒有任何行動就那麼它給錯誤分配,

Unable to find the controller for path "/login/check-google". Maybe you forgot to add the matching route in your routing configuration? 

即時通訊使用FOSUserBundle。

這是我config.yml,

hwi_oauth: 
     # configuration of oauth resource owners to use 
     resource_owners: 
      google: 
       type:    google 
       client_id:   xxxxxx.apps.googleusercontent.com 
       client_secret:  xxxxxxxxxxx 
       scope:    "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile" 
       options: 
        access_type:  online 

     # name of the firewall the oauth bundle is active in 
     firewall_name: secured_area 

     # optional FOSUserBundle integration 
     fosub: 
      # try 30 times to check if a username is available (foo, foo1, foo2 etc) 
      username_iterations: 30 

      # mapping between resource owners (see below) and properties 
      properties: 
       google: googleId 

     # if you want to use 'connect' and do not use the FOSUB integration, configure these separately 
     connect: ~ 


     # optional HTTP Client configuration 
     http_client: 
      timeout:  5 
      verify_peer: true 
      ignore_errors: true 
      max_redirects: 5 

Security.yml

security: 

     encoders: 
      FOS\UserBundle\Model\UserInterface: sha512 

     role_hierarchy: 
      ROLE_ADMIN:  ROLE_USER 
      ROLE_SUPER_ADMIN: ROLE_ADMIN 

     providers: 
      fos_userbundle: 
       id: fos_user.user_manager 

     firewalls: 
      main: 
       pattern:  .* 
       form-login: 
        provider:  fos_userbundle 
        login_path:  /login 
        use_forward: false 
        check_path:  /login_check 
        failure_path: null 
        default_target_path: /admin/dashboard 
       logout: 
        path: /admin/logout 
        target: /login 
       anonymous: true 

      secured_area: 
       pattern: ^/ 
       form_login: 
        provider: fos_userbundle 
        login_path: /connect 
        check_path: /login/login_check 
       anonymous: true 
       oauth: 
        resource_owners: 
         google:    "/login/check-google" 
        login_path:  /connect 
        failure_path:  /connect 

        # FOSUB integration 
        oauth_user_provider: 
         service: hwi_oauth.user.provider.fosub_bridge 

     access_control: 
      # The WDT has to be allowed to anonymous users to avoid requiring the login with the AJAX request 
      - { path: ^/wdt/, role: IS_AUTHENTICATED_ANONYMOUSLY } 
      - { path: ^/profiler/, role: IS_AUTHENTICATED_ANONYMOUSLY } 

      # AsseticBundle paths used when using the controller for assets 
      - { path: ^/js/, role: IS_AUTHENTICATED_ANONYMOUSLY } 
      - { path: ^/css/, role: IS_AUTHENTICATED_ANONYMOUSLY } 

      # URL of FOSUserBundle which need to be available to anonymous users 
      - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } 
      - { path: ^/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY } # for the case of a failed login 

的routing.yml

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

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

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

google_login: 
    pattern: /login/check-google 

回答

1

,我可以看到錯誤代碼中的第一件事就是Security.yml:

main防火牆的所有路由匹配

正則表達式「 *」 =‘0到無限次[貪婪]任何字符(除換行符)’

編輯防火牆的模式來匹配你想要路線讓他們負責,並考慮到如果一個模式匹配一​​個路由,下面的防火牆將不會被檢查。

firewalls: 
    secured_area: 
     pattern: ^/secured 
    main: 
     pattern: ^/ 

看看會發生什麼,如果您還有其他錯誤,我會相應地編輯我的回覆。