arietimmerman/laravel-saml

Laravel SAML 身份提供者包

v0.5.6 2022-11-03 20:26 UTC

README

Latest Stable Version Total Downloads

Laravel 的 SAML

这是一个使用 PHP 和 Laravel 编写的 SAML 身份提供者,基于 simplesamlphp/simplesamlphp 以及 adactive-sas/saml2-bridge-bundle 的部分代码构建。

它被 idaas.nl 使用:(不是)另一个身份即服务平台。

这个库(特别是文档)还在开发中

安装

composer require arietimmerman/laravel-saml

生成密钥对。

openssl req -new -x509 -days 3652 -nodes -out public.key -keyout private.key

排除 URL 的 CSRF 保护

class VerifyCsrfToken extends Middleware
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        '/saml/v2/*'
    ];
}

在你的 routes/web.php 文件中包含以下内容。

ArieTimmerman\Laravel\SAML\RouteProvider::routes();

在登录时,执行以下操作

Helper::getSAMLStateOrFail()->setAuthnContext(Constants::AC_KERBEROS);
Helper::saveSAMLState();

重定向到以下地址

'http://www.ice.test/saml/v2/continue/' . Helper::getSAMLStateOrFail()->id;

示例请求

http://samlidp.dev/saml/v2/login?SAMLRequest=...