uabookstores/laravel-shibboleth

此软件包最新版本(3.4)没有提供许可信息。

为Laravel 5.x启用基本Shibboleth支持

3.4 2022-02-10 21:02 UTC

README

本软件包为Laravel提供Shibboleth身份验证。

在开发过程中,它可以模拟一个IdP(通过mrclay/shibalike)。

Build Status Code Climate Code Coverage

安装

使用composer将最新版本添加到您的项目中

composer require uabookstores/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