clemsonmartech / laravel-shibboleth
为了支持现代 Laravel,基于 razorbacks/laravel-shibboleth 进行分支。
Requires
- illuminate/support: ^9.0 || ^10.0
- laravel/framework: ^9.0 || ^10.0
- mrclay/shibalike: 1.0.0
- php-open-source-saver/jwt-auth: ^1.4 || ^2.0
Provides
Replaces
This package is not auto-updated.
Last update: 2024-09-27 14:37:24 UTC
README
此包为 Laravel 提供 Shibboleth 认证。它是从 razorbacks/laravel-shibboleth 分支出来的。
在开发过程中,它可以模拟一个 IdP(通过 mrclay/shibalike)。
安装
使用 composer 将最新版本添加到您的项目中
composer require clemsonmartech/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 Tokens
如果您正在利用 tymon/jwt-auth 的令牌认证,请在您的 .env
中设置此变量
JWTAUTH=true