PHPackages                             codegreencreative/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. codegreencreative/laravel-samlidp

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

codegreencreative/laravel-samlidp
=================================

Make your PHP Laravel application an Identification Provider using SAML 2.0. 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).

v5.4.0(2mo ago)263763.5k↓13.7%91[7 PRs](https://github.com/codegreencreative/laravel-samlidp/pulls)1MITPHPPHP ^7.2.5|^8.0CI failing

Since Mar 20Pushed 1mo ago13 watchersCompare

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

READMEChangelog (10)Dependencies (10)Versions (67)Used By (1)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b548af35ef12350cf75f3d703613697888bc5600819fe77cd6ce291082ccc88e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f6465677265656e63726561746976652f6c61726176656c2d73616d6c6964702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codegreencreative/laravel-samlidp)[![Total Downloads](https://camo.githubusercontent.com/62e61bd9e74076a185da1f3b64e90e4f10e26656aa32513ce3d922e2ab6c4680/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f6465677265656e63726561746976652f6c61726176656c2d73616d6c6964702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codegreencreative/laravel-samlidp)

[Buy me a coffee](https://www.buymeacoffee.com/upwebdesign) ☕

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).

- Starting in version ^5.1, Laravel 9 is supported.
- Starting in version ^5.2.4, Laravel 10 is supported.
- Starting in version ^5.2.9, Laravel 11 is supported.

In this version we will be allowing for Laravel ^7.0 or ^8.0.

If you are looking for Laravel ^5.6 see [v1.0](https://github.com/codegreencreative/laravel-samlidp/tree/1.0)

If you are looking for Laravel ^6.0 use [v2.0](https://github.com/codegreencreative/laravel-samlidp/tree/2.0)

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

[](#installation)

```
composer require codegreencreative/laravel-samlidp
```

Configuration
=============

[](#configuration)

```
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]
```

Optionally, you can set the certificate and key using two environment variables: `SAMLIDP_CERT` and `SAMLIDP_KEY`.

Usage
-----

[](#usage)

Within your login view, probably `resources/views/auth/login.blade.php` add the SAMLRequest directive beneath the CSRF 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.

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:

```
php artisan samlidp:sp
```

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

```
