duanjuelu8874 2019-04-18 12:37
浏览 52

Symfony 3 - 无法在安全性上实现FOSUser登录,因为我也使用CAS身份验证

I would like to add my FOSUser login method on my security.yml, because I use a authentication CAS, but I want an authentication with a login-form on my homepage (with User table on database which is different to User from CAS authentication)

So I configured my security.yml like this :

# app/config/security.yml
security:
    encoders:
        FOS\UserBundle\Model\UserInterface: bcrypt

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
    app:
       id: bes_auth.user_provider

firewalls:

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

    public:
        pattern: ^accueil
        security: false
        anonymous: true

    main:
        logout_on_user_change: true
        pattern: ^/(admin|profile|packages|securiteInformatique|logout)
       # pattern: ^/(?!accueil)


        guard:
            authenticators:
                - app.security.login_form_authenticator:
                    check_path: fos_user_check_path

                - bes_auth.authenticator

        entry_point: Site\PagesBundle\Security\LoginFormAuthenticator


        logout:
            path:   deconnexion #nom de la route de déconnexion
            target: /
            success_handler: bes_auth.authenticator
        anonymous:    true

access_control:
    - { path: ^/admin, role: ROLE_SUPER_ADMIN }
    - { path: ^/accueil, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/, role: ROLE_USER }

But I've this error now :

Invalid type for path "security.firewalls.main.guard.authenticators.0". Expected scalar, but got array.

It's about :

        guard:
            authenticators:
                - app.security.login_form_authenticator:
                    check_path: fos_user_check_path

                - bes_auth.authenticator

            entry_point: Site\PagesBundle\Security\LoginFormAuthenticator

But I don't see what's wrong, can someone help me please ?

  • 写回答

1条回答 默认 最新

  • duanjue2560 2019-04-22 15:03
    关注

    just change your first Guard Authenticator without the option check_path: fos_user_check_path like this :

    ...........
    
    guard:
        authenticators:
            - app.security.login_form_authenticator
            - bes_auth.authenticator

    if you want more explain, this is the document: here

    thanks, I hope it's help you

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图