uisits / laravel-shibboleth
为Laravel 5.x启用基本Shibboleth支持
Requires
- illuminate/support: 5.* || ^6.0
- laravel/framework: ^5.4 || ^6.0
- mrclay/shibalike: 1.0.0
- tymon/jwt-auth: 1.0.x-dev
Requires (Dev)
- orchestra/testbench: 3.4.*
- phpunit/phpunit: ^6.0
README
此包是 uabookstores/laravel-shibboleth 的精确副本,支持 Laravel ^5.7
此包为Laravel提供Shibboleth身份验证。
在开发过程中,它可以 模拟 IdP(通过 mrclay/shibalike)。
安装
使用 composer 将最新版本添加到您的项目中
composer require uisits/laravel-shibboleth
如果您正在运行Laravel >= 5.5,则可以跳过此步骤,否则您需要手动在 config/app.php
文件中的 Providers
数组中注册服务提供者。
StudentAffairsUwm\Shibboleth\ShibbolethServiceProvider::class,
如果您想通过shibalike使用模拟的IdP,那么您需要在任何版本上手动注册它 - 即使在Laravel 5.5中也不会自动加载。
StudentAffairsUwm\Shibboleth\ShibalikeServiceProvider::class,
注意 shibalike的密码与用户名相同。
发布默认配置文件
php artisan vendor:publish --provider="StudentAffairsUwm\Shibboleth\ShibbolethServiceProvider"
可选地,您还可以发布shibalike模拟IdP登录的视图
php artisan vendor:publish --provider="StudentAffairsUwm\Shibboleth\ShibalikeServiceProvider"
亚利桑那大学用户
要使用IdP注销,请在
config/shibboleth.php
中设置以下内容'idp_logout' => '/Shibboleth.sso/Logout?return=https%3A%2F%2Fshibboleth.arizona.edu%2Fcgi-bin%2Flogout.pl',
在您的 config/auth.php
文件中将驱动程序更改为 shibboleth
。
'providers' => [ 'users' => [ 'driver' => 'shibboleth', 'model' => App\User::class, ], ],
现在用户可以通过访问 https://example.com/shibboleth-login
通过Shibboleth登录,并使用 https://example.com/shibboleth-logout
注销,这样您可以根据登录表单中的电子邮件地址提供自定义链接或重定向。
@if (Auth::guest()) <a href="/shibboleth-login">Login</a> @else <a href="/shibboleth-logout"> Logout {{ Auth::user()->name }} </a> @endif
您可以在 config/shibboleth.php
中配置服务器变量映射,例如用户的首字母、姓氏、权益等。您可以通过阅读身份验证后填充到 $_SERVER
变量中的内容来查看它们。
<?php print_r($_SERVER);
映射的值将在身份验证成功后同步到用户表中。
授权
您可以使用当前用户的权益字符串进行静态检查
$entitlement = 'urn:mace:uark.edu:ADGroups:Computing Services:Something'; if (Entitlement::has($entitlement)) { // authorize something }
现在您可以为这些权益起草 策略和闸门。
本地用户
此设计旨在与本地身份验证系统并行使用,适用于希望同时拥有Shibboleth和本地用户的项目的场景。如果您想允许本地注册以及验证Shibboleth用户,则使用Laravel内置的认证系统。
php artisan make:auth
JWTAuth令牌
如果您正在利用 tymon/jwt-auth 的令牌认证,请在您的 .env
中设置此变量
JWTAUTH=true