symfony - 找到使用哪个保护身份验证器

时间:2017-11-02 09:40:14

标签: php symfony security

我的security.yml看起来像这样

security:
encoders:
    AppBundle\Entity\User: bcrypt
    AppBundle\Entity\Agency: bcrypt
providers:
    chain_provider:
            chain:
                providers: [agency_db, user_db]
    user_db:
        entity: { class: AppBundle:User, property: email }
    agency_db:
        entity: { class: AppBundle:Agency, property: email }

LE

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: ~
        guard:
            authenticators:
            - app.form_login_authenticator
            - app.agency_form_login_athenticator
            entry_point: AppBundle\Security\FormLoginAuthenticator
        logout:
          path: /logout
          target: /
    agency:
        pattern: ^/agency/
        guard:
            authenticators:
            - AppBundle\Security\AgencyFormLoginAuthenticator
        logout:
          path: /logout_agency
          target: /
access_control:
          - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
          - { path: ^/agency, roles: ROLE_AGENCY }
          - { path: ^/, roles: [IS_AUTHENTICATED_ANONYMOUSLY, ROLE_USER] }

我需要弄清楚使用了哪个提供商,所以当我从令牌存储中获取电子邮件时

$a = $this->get('security.token_storage')->getToken()->getUser();

我需要知道从哪里获取数据 - 我应该查询哪个实体

0 个答案:

没有答案