alexandret / phpcas-guard-bundle
适用于 Symfony3.4 及以上版本的 PhpCAS Bundle,使用 guard 进行认证
1.0.2
2020-05-14 09:24 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认证
此bundle 不提供 CAS服务器。使用此bundle,您的应用程序将能够使用您的Cas服务器来认证用户。
安装
步骤 1: 下载 Bundle
打开命令行,进入您的项目目录并执行以下命令以下载此bundle的最新稳定版本
$ composer require "alexandret/phpcas-guard-bundle" "~1"
此命令要求您全局安装了Composer,如Composer文档中的安装章节所述。
步骤 2: 启用 Bundle
通过将其添加到项目 config/bundles.php
文件中注册的bundle列表中,启用此bundle
<?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章中实现的登录表单认证器的调用,并用此bundle中声明的 phpcasguard.cas_authenticator
替换它。
步骤 4: 配置 Bundle
创建一个 config\packages\cas_guard.yaml
文件
cas_guard: hostname: '%env(CAS_HOSTNAME)%' # ...
查看完整的配置文件以完成配置并将其与您的CAS服务器连接。