PHPackages                             juhedata/laravel-samlidp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. juhedata/laravel-samlidp

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

juhedata/laravel-samlidp
========================

Make your Laravel application an Idenification Provider using SAML 2.0.

v2.0.5(6y ago)02.3kMITPHPPHP ^7.2

Since Mar 20Pushed 5y agoCompare

[ Source](https://github.com/juhedata/laravel-samlidp)[ Packagist](https://packagist.org/packages/juhedata/laravel-samlidp)[ RSS](/packages/juhedata-laravel-samlidp/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (9)Dependencies (3)Versions (36)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b085d9af002bbfd40a70250e7e7ebf9818577f26ac8d5ea6a4a6e8b3c38813db/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a756865646174612f6c61726176656c2d73616d6c6964702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/juhedata/laravel-samlidp)[![Total Downloads](https://camo.githubusercontent.com/9d4a694b10d988c1b3d99bd3b577d73b9a37cbd6a4f76e9096e1db2709f35867/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a756865646174612f6c61726176656c2d73616d6c6964702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/juhedata/laravel-samlidp)

Laravel SAML IdP
================

[](#laravel-saml-idp)

This package allows you to implement your own Identification Provider (idP) using the SAML 2.0 standard to be used with supporting SAML 2.0 Service Providers (SP).

该组件可以让你实现基于SAML 2.0协议的IDP端（IDP端提供身份验证，用户在此登录）。

Version
-------

[](#version)

1.0

- Laravel 5.X required

2.0

- PHP 7.2+ required
- Laravel 6.X required

Installation
------------

[](#installation)

Require this package with composer:

用composer安装本组件：

```
composer require juhedata/laravel-samlidp:^2.0
```

Publish config

发布配置文件

```
php artisan vendor:publish --tag="samlidp_config"
```

FileSystem configuration

文件系统配置

```
// config/filesystem.php

'disks' => [

        ...

        'samlidp' => [
            'driver' => 'local',
            'root' => storage_path() . '/samlidp',
        ]
],
```

Use the following command to create a self signed certificate for your IdP. If you change the certname or keyname to anything other than the default names, you will need to update your `config/samlidp.php` config file to reflect those new file names.

用以下命令生成自签证书

```
php artisan samlidp:cert [--days  --keyname  --certname ]
```

```
Options:
  --days=      Days to add for the expiration date [default: 7800]
  --keyname=   Name of the certificate key file [default: key.pem]
  --certname=  Name of the certificate file [default: cert.pem]
```

Usage
-----

[](#usage)

Within your login view, probably `resources/views/auth/login.blade.php` add the SAMLRequest directive beneath the CSRF directive:

在登录页面（如`resources/views/auth/login.blade.php`），在CSRF directive后增加SAMLRequest directive

```
@csrf
@samlidp
```

The SAMLRequest directive will fill out the hidden input automatically when a SAMLRequest is sent by an HTTP request and therefore initiate a SAML authentication attempt. To initiate the SAML auth, the login and redirect processes need to be intervened. This is done using the Laravel events fired upon authentication.

SAMLRequest directive会自动检查当前的HTTP请求是否含有SAML相关的参数，若有则补充SAML相关的参数到登录的表单中。 相关中间件会处理表单中的SAML请求，并将用户重定向到SP。

Config
------

[](#config)

After you publish the config file, you will need to set up your Service Providers. The key for the Service Provider is a base 64 encoded Consumer Service (ACS) URL. You can get this information from your Service Provider, but you will need to base 64 encode the URL and place it in your config. This is due to config dot notation.

You may use this command to help generate a new SAML Service Provider:

一个idP可以对应多个SP，用以下命令生成SP配置代码：

```
php artisan samlidp:sp
```

Example SP in `config/samlidp.php` file:

可参考 `config/samlidp.php` 文件中的SP配置示例：

```
