cblink/laravel-sso
Composer 安装命令:
composer require cblink/laravel-sso
包简介
README 文档
README
install
composer require cblink/laravel-sso -vvv
configure
publish config.php and migration
php artisan vendor:publish --provider="Cblink\Sso\SsoServiceProvider"
migrate:
php artisan migrate
this command will create a table name sso to authorize.
create sso route:
php artisan sso:route
also you can create sso through command
php artisan sso:create
add to your auth.php:
'guards' => [ 'sso' => [ 'driver' => 'session', 'provider' => 'sso', ], ], 'providers' => [ 'sso' => [ 'driver' => 'sso', 'table' => 'sso', ], ],
usage
Get ticket in client
// sso client system Route::get('sso', function () { $client = new \GuzzleHttp\Client(); $response = $client->get('http://yourdomain/sso/getTicket?'.http_build_query([ 'app_id' => 'your_app_id', 'secret' => 'your_secret', ])); $result = json_decode((string)$response->getBody(), true); if ($ticket = $result['ticket'] ?? null) { return redirect('http://yourdomain/sso/login?ticket='.$ticket); } });
Redirect to any url
add middleware to Http/kernel.php
protected $routeMiddleware = [ // ... 'ticket' => \Cblink\Sso\Http\Middleware\LoginWithTicket::class, ]; // declare route priority protected $middlewarePriority = [ \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \Cblink\Sso\Http\Middleware\LoginWithTicket::class, \Illuminate\Auth\Middleware\Authenticate::class, \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Auth\Middleware\Authorize::class, ];
in web.php , add ticket before auth:
Route::group(['middleware' => ['ticket', 'auth'], function () { // ... });
cblink/laravel-sso 适用场景与选型建议
cblink/laravel-sso 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.78k 次下载、GitHub Stars 达 123, 最近一次更新时间为 2018 年 07 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cblink/laravel-sso 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cblink/laravel-sso 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.78k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 123
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-16