codeplace-io/phpcas-guard-bundle

PhpCAS Bundle,用于Symfony3.4及更高版本的安全防护

安装: 60

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 3

类型:symfony-bundle

1.0.3 2021-05-21 18:35 UTC

This package is auto-updated.

Last update: 2024-09-22 02:06:42 UTC


README

PhpCas Bundle提供使用guard进行symfony 3.4+和4的CAS认证

此捆绑包不提供CAS服务器。使用此捆绑包后,您的应用程序将能够使用您的Cas服务器来验证用户。
SymfonyInsight Coverage Status Build Status

安装

步骤1:下载捆绑包

打开命令行界面,进入您的项目目录,并执行以下命令以下载此捆绑包的最新稳定版本

$ composer require "alexandret/phpcas-guard-bundle" "~1"

此命令需要您全局安装Composer,请参阅Composer文档中的安装章节

步骤2:启用捆绑包

将捆绑包添加到项目中config/bundles.php文件中注册的捆绑包列表以启用它

<?php

return [
    //...
    AlexandreT\Bundle\CasGuardBundle\CasGuardBundle::class => ['all' => true],
];

步骤3:启用安全

更新您的config\packages\security.yaml文件

#https://symfony.com.cn/doc/current/reference/configuration/security.html#full-default-configuration
security:
    # ...
    firewalls:
        #Main firewall
        main:
            # We use Guard !
            guard:
                authenticators:
                    # ADD the cas authenticator declared in this bundle
                    - phpcasguard.cas_authenticator
            # The logout path
            logout:
                # This route will be never called because of listener. It will catch it and redirect user.                
                path: /logout
                # ADD the same cas authenticator declared in this bundle to activate logout function
                success_handler: phpcasguard.cas_authenticator  
    # ...

从Symfony 2.8开始,Guard提供了一种新的、优秀的方式来验证。我建议您查看此优秀的教程以了解Guard的功能。此教程解释了如何使用guard登录表单生成标准认证。当您理解了它后,您只需禁用第5章中实现的登录表单验证器调用,并用此捆绑包内声明的phpcasguard.cas_authenticator替换即可。

步骤4:配置捆绑包

创建一个config\packages\cas_guard.yaml文件

cas_guard:
    hostname: '%env(CAS_HOSTNAME)%'
    # ...

请参阅完整的配置文件来完成配置并将其连接到您的CAS服务器。