2017-08-31 1 views
1

同じルートを使用して、ログインとOAuthクライアントの両方の認証情報を使ってアクセスするSymfonyアプリケーションがあります。ログインとOauth2クライアントの資格情報で同じルートを認証するときに匿名アクセスが動作しない

私は、次のファイアウォールの設定でこれを達成している:

firewalls: 
    # disables authentication for assets and the profiler, adapt it according to your needs 
    dev: 
     pattern: ^/(_(profiler|wdt)|css|images|js)/ 
     security: false 

    oauth: 
     pattern: ^/ 
     stateless: true 
     simple_preauth: 
      authenticator: AppBundle\Security\AccessTokenAuthenticator 
     provider: access_token_user_provider 

    main: 
     anonymous: ~ 
     # activate different ways to authenticate 

     # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate 
     http_basic: ~ 

     provider: chain_provider 
     # https://symfony.com/doc/current/security/form_login_setup.html 
     form_login: 
      login_path: login 
      check_path: login 
      csrf_token_generator: security.csrf.token_manager 
      #failure_path: login_failure 

     logout: 
      path: /logout 
      invalidate_session: true 

access_control: 
    - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY } 
    - { path: ^/site/signup, roles: IS_AUTHENTICATED_ANONYMOUSLY } 
    - { path: ^/site/get_token, roles: IS_AUTHENTICATED_ANONYMOUSLY } 
    - { path: ^/, roles: [ROLE_CUSTOMER, ROLE_PARTNER] } 

は、私がこれを行うときしかし、一番下にあるすべての匿名のルートは、現在だけでなくAccessTokenAuthenticatorでチェックされ、もう動作しません。

profilerルートのように手動で除外する必要がありますか、それともaccess_control:entriesを使用してそれらをすべて処理する方が良いでしょうか?

答えて

1

私は、セキュリティファイル内のルールの順序が異なるかもしれないと思います。あなたはそのように言いますか?

firewalls: 
    # disables authentication for assets and the profiler, adapt it according to your needs 
dev: 
    pattern: ^/(_(profiler|wdt)|css|images|js)/ 
    security: false 

# First Main Firewall 
main: 
    anonymous: ~ 
    # activate different ways to authenticate 

    # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate 
    http_basic: ~ 

    provider: chain_provider 
    # https://symfony.com/doc/current/security/form_login_setup.html 
    form_login: 
     login_path: login 
     check_path: login 
     csrf_token_generator: security.csrf.token_manager 
     #failure_path: login_failure 

    logout: 
     path: /logout 
     invalidate_session: true 

# Second Oauth Firewall 
oauth: 
    pattern: ^/ 
    stateless: true 
    simple_preauth: 
     authenticator: AppBundle\Security\AccessTokenAuthenticator 
    provider: access_token_user_provider 
+0

申し訳ありませんが、実際になし、複数のファイアウォールを使用して、私は今までつの認証方式が軌道に乗ることができ、ログインファイアウォールがであるときtop、access_controlのルールは機能しません – jdog

0

は、私は同じファイアウォールで複数の認証プロバイダを使用してこれを解決:

firewalls: 
    # disables authentication for assets and the profiler, adapt it according to your needs 
    dev: 
     pattern: ^/(_(profiler|wdt)|css|images|js)/ 
     security: false 
    main: 
     anonymous: ~ 
     # activate different ways to authenticate 

     # https://symfony.com/doc/current/security.html#a-configuring-how-your-users-will-authenticate 
     http_basic: ~ 

     provider: chain_provider 
     # https://symfony.com/doc/current/security/form_login_setup.html 
     simple_preauth: 
      authenticator: AppBundle\Security\AccessTokenAuthenticator 
      provider: access_token_user_provider 
     form_login: 
      login_path: login 
      check_path: login 
      csrf_token_generator: security.csrf.token_manager 
      #failure_path: login_failure 

     logout: 
      path: /logout 
      invalidate_session: true 
関連する問題