dpazuic/laravel-shibboleth

该软件包最新版本(v11.0.2)没有提供许可信息。

为 Laravel 5.x 启用基本 Shibboleth 支持。由 razorbacks/laravel-shibboleth 分支。

v11.0.2 2024-04-25 17:09 UTC

This package is auto-updated.

Last update: 2024-09-25 18:34:49 UTC


README

razorbacks/laravel-shibboleth 分支,用于伊利诺伊大学芝加哥分校,以提供 Laravel 的 Shibboleth 认证。此软件包为 UIC 提供了 Laravel 的 Shibboleth 认证。

Code Coverage

先决条件

为了使用此插件,我们假设您已经配置了现有的 Shibboleth SP 和 Shibboleth IdP。这不会(也不会)解释如何设置这些内容。

安装

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

composer require dpazuic/laravel-shibboleth

如果您正在运行 Laravel >= 5.5,则可以跳过此步骤,否则您需要手动在您的 config/app.php 文件中的 Providers 数组中注册服务提供者。

StudentSystemServices\Shibboleth\ShibbolethServiceProvider::class,

如果您想通过 shibalike 使用模拟 IdP,则需要在任何版本中手动注册它 - 即使在 Laravel 5.5 中也不会自动加载。

StudentSystemServices\Shibboleth\ShibalikeServiceProvider::class,

发布默认配置文件

php artisan vendor:publish --provider="StudentSystemServices\Shibboleth\ShibbolethServiceProvider"

在您的 config/auth.php 文件中将驱动程序更改为 shibboleth

'providers' => [
    'users' => [
        'driver' => 'shibboleth',
        'model'  => App\User::class,
    ],
],

现在用户可以通过访问 https://example.uic.edu/shibboleth-login 通过 Shibboleth 登录,并使用 https://example.uic.edu/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);

映射的值将在认证成功后同步到用户表中。

声明登录路由

按照惯例,laravel 假设存在一个名为 login 的路由来重定向未认证的请求

此软件包将路由命名为 shibboleth-login,因为它旨在与其他认证提供程序一起使用,例如 artisan 提供的默认脚手架。但如果这是唯一的认证提供程序,则需要手动声明此名称。例如:

Route::name('login')->get('/login', '\\'.Route::getRoutes()->getByName('shibboleth-login')->getActionName());

或更易读,但有重定向

Route::redirect('/login', '/shibboleth-login')->name('login');

本地用户

此软件包旨在与本地认证系统并行使用,适用于您想同时使用 Shibboleth 和本地用户的项目的场景。如果您想允许本地注册以及认证 Shibboleth 用户,则可以使用 Laravel 内置的认证系统。

php artisan make:auth