2017-08-08 12 views
0

は、私はすべてのエンドポイントにセキュリティを追加したいバック同じパターンでsymfony 2.8で複数のファイアウォールを使用するには?

を終了RESTのAPIとして使用されるのsymfony 2.8のアプリケーションを持っているマッチング^/API私は3種類の認証方法を使用できるようにしたいと思い ^/api

uma/psr7-hmac-bundle、friendsofsymfony/oauth-server-bundle、APIKey認証を使用しています。

私は3つの異なるファイアウォールを定義しました。他の2つを削除すると、ファイアウォールごとにすべてが機能します。

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

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

     oauth_authorize: 
      pattern: ^/oauth/v2/auth 
      security: false 

     api_key: 
      pattern: ^/api 
      stateless: true 
      simple_preauth: 
       authenticator: api_key_authenticator 
      provider: api_key_user_provider 

     oauth_api: 
      pattern: ^/api 
      stateless: true 
      fos_oauth: true 
      provider: oauth_user 

     hmac_api: 
      pattern: ^/api 
      stateless: true 
      hmac: 
       apikey_header: 'X-Custom-Header-Key' 
      provider: hmac_user 

どのように3つのファイアウォールを一緒に使用できますか? (hmac_api、oauth_api、api_key)

私はガードに目を通しましたが、HMACとoAuthの認証者を定義/実装する方法がわかりません。

私はファイアウォールのコンテキストを調べましたが、ステートレスなので機能しません。

基本的に同じパターンで複数のファイアウォールをチェーンすることはできますか?または私がfriendsofsymfony/oauth-server-bundle、uma/psr7-hmac-bundleのような3番目のバンドルを使用していることを考慮して、3つの異なるオーセンティケータで1つのファイアウォールを定義する方法はありますか?

答えて

0

使用私は私のアプリに持っているもの

api: 
      pattern: ^/api   
      guard: 
       authenticators: 
        - bor.api_bundle.session_authenticator 
        - lexik_jwt_authentication.jwt_token_authenticator 
        - sergei_k_security.token_authenticator 
       entry_point: lexik_jwt_authentication.jwt_token_authenticator 

ドキュメントだファイアウォール のための連鎖認証者のための

guard: 
    authenticators: 

- あなたはUMA/psr7-HMACのための認証子を定義する方法http://symfony.com/doc/current/security/multiple_guard_authenticators.html

+0

-bundle、friendsofsymfony/oauth-server-bundle? – PMoubed

+0

https://symfony.com/doc/current/security/guard_authentication.html –

関連する問題