maciejkogut / laravel-shibboleth-cvm
基于 jhu-wse/laravel-shibboleth 进行修改,以便支持我们的 Laravel 应用程序
Requires
- illuminate/support: ^9.0 || ^10.0 | ^11.0
- laravel/framework: ^9.0 || ^10.0 | ^11.0
- mrclay/shibalike: ^1.0.0
- php-open-source-saver/jwt-auth: ^1.4 || ^2.0
Provides
- jhu-wse/laravel-shibboleth: v1.0.0
- uabookstores/laravel-shibboleth: v1.0.0
Replaces
- jhu-wse/laravel-shibboleth: v1.0.0
- uabookstores/laravel-shibboleth: v1.0.0
This package is auto-updated.
Last update: 2024-09-23 22:00:59 UTC
README
此包为 Laravel 提供 Shibboleth 认证。它是从 uabookstores/laravel-shibboleth 分支出来的。
为了开发,它可以通过 mrclay/shibalike 模拟 IdP。
安装
使用 composer 将最新版本要求添加到您的项目中
composer require jhu-wse/laravel-shibboleth
如果您想通过 shibalike 使用模拟的 IdP,那么您需要在任何版本上手动注册它 - 这不是自动加载的。
Jhu\Wse\LaravelShibboleth\ShibalikeServiceProvider::class,
注意 shibalike 的密码与用户名相同。
发布默认配置文件
php artisan vendor:publish --provider="Jhu\Wse\LaravelShibboleth\ShibbolethServiceProvider"
可选地,您还可以发布 shibalike 模拟的 IdP 登录视图
php artisan vendor:publish --provider="Jhu\Wse\LaravelShibboleth\ShibalikeServiceProvider"
在您的 config/auth.php
文件中将驱动程序更改为 shibboleth
。
'providers' => [ 'users' => [ 'driver' => 'shibboleth', 'model' => App\Models\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);
如果配置设置 shibboleth.update_users
设置为 true
(默认值),则映射值将在认证成功后将同步到用户表中。要禁用更新,请将 shibboleth.update_users
设置为 false
。
授权
您可以静态地检查当前用户的权益字符串
$entitlement = 'urn:mace:uark.edu:ADGroups:Computing Services:Something'; if (Entitlement::has($entitlement)) { // authorize something }
现在您可以为这些权益创建 策略和门。
JWTAuth 令牌
如果您正在利用 tymon/jwt-auth 的令牌认证,请在此 .env
中设置此变量
JWTAUTH=true