2012-12-07 10 views
11

FOSUserBundleを私のFOSOAuthServerBundle対応サーバの認証プロバイダに設定しようとしています。私がFOSUserBundleを実装しようとする前に、FOSOAuthServerBundleが正しく動作していて、FOSOAuthServerBundleを使わずにFOSUserBundleを動作させていましたが、一緒に動作させることはできません。FOSUserBundleを私のFOSOAuthServerBundle対応サーバの認証プロバイダに設定する方法

私の質問は、下記のsecurity.ymlのoauth_authorize:firewallの認証プロバイダに指定する必要がありますか?

# app/config/security.yml 
security: 
    providers: 
    fos_userbundle: 
     id: fos_user.user_provider.username 

    encoders: 
     FOS\UserBundle\Model\UserInterface: sha512 

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

     oauth_authorize: 
      pattern: ^/oauth/v2/auth 

      # WHAT GOES HERE? 

     api: 
      pattern: ^/api 
      fos_oauth: true 
      stateless: true 

    access_control: 
     - { path: ^/api, roles: [ IS_AUTHENTICATED_FULLY ] } 

私はクライアントではなくユーザーを認証しようとしています。どうもありがとう。

答えて

0

あなたのconfig.ymlでのOAuthサーバー

fos_oauth_server: 
    db_driver: orm 
    client_class:  {PATH TO ENTITY}\Client 
    access_token_class: {PATH TO ENTITY}\AccessToken 
    refresh_token_class: {PATH TO ENTITY}\RefreshToken 
    auth_code_class:  {PATH TO ENTITY}\AuthCode 
     service: 
      user_provider: fos_user.user_provider.username 

ため

fos_user: 
    db_driver: orm 
    firewall_name: main 
    user_class: Zoef\UserBundle\Entity\Userere 

そして、このようなものを、次のを持っていなければならないとのsecurity.ymlは次のようになります。

security: 
    encoders: 
     FOS\UserBundle\Model\UserInterface: sha512 
    providers: 
     fos_userbundle: 
      id: fos_user.user_provider.username 
    firewalls: 
     oauth_token: 
      pattern: ^/oauth/v2/token 
      security: false 

    access_control: 
    - { path: ^/, roles: ROLE_ADMIN } 

URLにアクセスしたときに、次のような応答を得る必要があるため、動作しているかどうかテストできます。 "error": "access_denied"、 "error_description": "OAuth2 authentication required"}

関連する問題