dsi-iepg/cas-connection
Composer 安装命令:
composer require dsi-iepg/cas-connection
包简介
Mise en place d'une authentification par CAS
README 文档
README
The bundle make and authenicator with and phpCas based on the login of user.
If you want multiple authenticator anser yes for does need passwords => yes.
installation
The authenticator use 2 role:
- USER
- ADMIN
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
$ composer require dsi-iepg/cas-connection
Create User with login
$ php bin/console make:user
- name class => User
- store user data in the database => yes
- property name => login
- does need passwords => no
make and play migrations with Doctrine.
files modifications
Add in config/bundles.php
return [
...
Iepg\Bundle\Cas\CasConnectionBundle::class => ['all' => true],
]
Add in .env
#.env
...
#### Parameters for CAS connection ###
CAS_HOST=cas-adresse.com
# This value is optional
# If it's empty the path will the base url"
# example: scheme://httpHost+BasePath"
CAS_PATH=
# Default value 443"
CAS_PORT=443
# This value is optional
# if it's 'false' you don't use ceretificat
# THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION!
CAS_CA=false
# The path start to the DocumentRoot generaly public
# example if your file was at the root of project
# CAS_CA_PATH=../certificat
CAS_CA_PATH=
# this value is optional. You can custome the NAME of the dispatcher route
# Where does the user go according to his role
# The default value is 'cas_dispatcher'
CAS_DISPATCHER_NAME=
# this value is optional. YOU CAN CUSTOMIZE THE PAGE WHEN A USER IS SUCCESSFULLY AUTHENTICATED
# BUT DOES NOT HAVE ACCESS RIGHTS TO THIS APPLICATION
CAS_USER_UNKNOW=
#### end of Cas-connection ####
...
Add in config/packages/security.yaml
#config/packages/security.yaml
...
firewalls:
main:
provider: app_user_provider
custom_authenticator: Iepg\Bundle\Cas\Controller\CasAuthenticator
...
Or if you use multiple authenticators
#config/packages/security.yaml
...
firewalls:
main:
...
#choose the first authenticator you want.
entry_point: App\Security\AppAuthenticator
custom_authenticator:
- Iepg\Bundle\Cas\Controller\CasAuthenticator
- App\Security\AppAuthenticator
...
And add
access_control:
- { path: ^/cas_, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- ...
WARNING! For attention reasons, please avoid starting your own route with 'cas_'
add Files
Add file in config/packages/cas_connection.yaml
#config/packages/cas_connection.yaml
cas_connection:
cas_host: "%env(CAS_HOST)%"
cas_path: "%env(CAS_PATH)%"
cas_port: "%env(int:CAS_PORT)%"
cas_ca: "%env(bool:CAS_CA)%"
cas_ca_path: "%env(CAS_CA_PATH)%"
cas_dispatcher_name: "%env(CAS_DISPATCHER_NAME)%"
twig:
paths:
"%kernel.project_dir%/vendor/dsi-iepg/cas-connection/src/Resources/views": cas_connection
Add in file config/routes.yaml
#config/routes/cas_connection.yaml cas_login: path: /cas_login controller: Iepg\Bundle\Cas\Controller\CasAuthenticator cas_logout: path: /cas_logout cas_dispatcher: path: /cas_dispatcher controller: Iepg\Bundle\Cas\Controller\CasController::dispatcher
Add file in src/EventListener/logoutSubcriber.php
//src/EventListener/logoutSubcriber.php namespace App\EventListener; use Iepg\Bundle\Cas\Controller\CasLogout; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Http\Event\LogoutEvent; class LogoutSubscriber implements EventSubscriberInterface { private $casLogout; public function __construct(CasLogout $casLogout) { $this->casLogout = $casLogout; } public static function getSubscribedEvents(): array { return [LogoutEvent::class => 'onLogout']; } public function onLogout(LogoutEvent $event): void { $this->casLogout->logout($event->getRequest()); } }
dsi-iepg/cas-connection 适用场景与选型建议
dsi-iepg/cas-connection 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 269 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 12 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cas」 「casphp」 「iepg」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dsi-iepg/cas-connection 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dsi-iepg/cas-connection 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dsi-iepg/cas-connection 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Add CAS server SSO authentication to Laravel 4 and 5
CAS bundle for PuMuKIT
Basic CAS (SSO) authenticator for Symfony 5.4, 6.0, 7.0 and 8.0
Symfony Lock Component
Provides a simple API for authenticating users against a CAS server
Provides a simple API for authenticating users against a CAS server for Laravel
统计信息
- 总下载量: 269
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-12