如何用交响乐同时进行多种身份验证

时间:2019-06-17 17:14:50

标签: api symfony authentication saml-2.0 api-key

我是symfony的新用户,对于我的工作,我需要在symfony 2.8中添加一种新的身份验证方法,因为我有一个具有saml身份验证的网站,并且我希望添加具有简单api令牌身份验证的API服务,如交响文档。

我已经尝试过以下官方方式:https://symfony.com/doc/4.0/security/api_key_authentication.html

以这种方式:https://www.cloudways.com/blog/symfony-api-token-authentication/

这是我的安全性文件,另一个文件是过去的副本 https://www.cloudways.com/blog/symfony-api-token-authentication/ 带有名称空间和可变的个性化

security:


    providers:
        in_memory:
            memory: ~
        db_provider:
            entity:
                class: censored\CoreBundle\Entity\User
                property: username

        api_key_user_provider:
           entity:
               class: censored\CoreBundle\Entity\User
               property: apikey


    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        light_saml_sp:
                  pattern: ^/
                  provider: db_provider
                  user_creator: user_creator
                  login_path: /saml/login
                  check_path: /saml/login_check
        logout:
              path: /logout
              target: default
              invalidate_session: false
              success_handler: censored.logout_handler
        anonymous: ~



        api:
           pattern: ^/api/
           anonymous: true
           stateless: true
           provider: api_key_user_provider
           guard:
                authenticators:
                    - censored\CoreBundle\Security\TokenAuthenticator



    access_control:
        - { path: ^/saml/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin, roles: ROLE_EXPERT }
        - { path: ^/, roles: ROLE_USER }

    role_hierarchy:
        ROLE_PREMIUM:   ROLE_USER
        ROLE_EXPERT:    ROLE_PREMIUM
        ROLE_ADMIN: ROLE_EXPERT


当我最后一次遇到此错误时

  

[Symfony \ Component \ Config \ Definition \ Exception \ InvalidConfigurationException]   下的无法识别的选项“ user_creator,login_path,check_path”   “ security.firewalls.light_saml_ sp”

但是此防火墙以前可以正常工作。

0 个答案:

没有答案