codeplace-io / phpcas-guard-bundle
PhpCAS Bundle,用于Symfony3.4及更高版本的安全防护
1.0.3
2021-05-21 18:35 UTC
Requires
- php: >=7.1.3
- jasig/phpcas: ~1.3
- symfony/config: ~3.4|4.*|~5.0
- symfony/dependency-injection: ~3.4|4.*|~5.0
- symfony/routing: ~3.4|4.*|~5.0
- symfony/security-guard: ~3.4|4.*|~5.0
- symfony/yaml: ~3.4|4.*|~5.0
Requires (Dev)
- codeception/aspect-mock: *
- phpunit/phpunit: ~7.5
- symfony/debug: ~3.4|4.*|~5.0
- symfony/phpunit-bridge: ~3.4|4.*|~5.0
README
PhpCas Bundle提供使用guard进行symfony 3.4+和4的CAS认证
此捆绑包不提供CAS服务器。使用此捆绑包后,您的应用程序将能够使用您的Cas服务器来验证用户。
安装
步骤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服务器。