PHPackages                             jdlien/laravel-saml - 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. jdlien/laravel-saml

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

jdlien/laravel-saml
===================

SAML toolkit for Laravel based on OneLogin's SAML PHP Toolkit.

2.1.0(2mo ago)114MITPHPPHP ^8.3CI passing

Since May 19Pushed 2mo agoCompare

[ Source](https://github.com/jdlien/laravel-saml)[ Packagist](https://packagist.org/packages/jdlien/laravel-saml)[ Docs](https://github.com/jdlien/laravel-saml)[ RSS](/packages/jdlien-laravel-saml/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (9)Versions (7)Used By (0)

Laravel SAML
============

[](#laravel-saml)

[![CI](https://github.com/jdlien/laravel-saml/actions/workflows/ci.yml/badge.svg)](https://github.com/jdlien/laravel-saml/actions/workflows/ci.yml)[![Packagist Version](https://camo.githubusercontent.com/e7266dc1fe686ad68c5a5c11d739493a501e14a0a34295cde26e656e870cfa9c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a646c69656e2f6c61726176656c2d73616d6c2e7376673f763d32)](https://packagist.org/packages/jdlien/laravel-saml)[![Total Downloads](https://camo.githubusercontent.com/b70abe19e570d4e112179f39a3d35513c0c2c57eddcea21a5d728471c58132d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a646c69656e2f6c61726176656c2d73616d6c2e7376673f763d32)](https://packagist.org/packages/jdlien/laravel-saml)[![License](https://camo.githubusercontent.com/4ad1ad198e28551ca2e5f40eefc673d9359937af477cbbffb49909d9f3202e53/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a646c69656e2f6c61726176656c2d73616d6c2e7376673f763d32)](https://packagist.org/packages/jdlien/laravel-saml)

A SAML 2.0 toolkit for Laravel, built around [SAML-Toolkits/php-saml](https://github.com/SAML-Toolkits/php-saml) (on packagist as `onelogin/php-saml`).

Requirements
------------

[](#requirements)

- PHP `^8.3`
- Laravel `^12.0` or `^13.0`
- `ext-openssl`

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

[](#installation)

```
composer require jdlien/laravel-saml
```

The service provider is auto-discovered. Publish the config:

```
php artisan vendor:publish --tag=saml-config
```

This creates `config/saml.php`. The shape mirrors the [OneLogin PHP toolkit settings](https://github.com/SAML-Toolkits/php-saml#settings); see that project's docs for advanced options.

Configuration
-------------

[](#configuration)

### Single IdP

[](#single-idp)

If your application authenticates against a single IdP, fill in the `idp` section of `config/saml.php` (or supply the corresponding `SAML_IDP_*` env vars). The package auto-registers the resolver on boot.

### Multiple IdPs

[](#multiple-idps)

For multi-IdP scenarios, leave `idp` unset in `config/saml.php` and register a resolver from a service provider:

```
use Jdlien\LaravelSaml\Saml;

Saml::configureIdpUsing(function (string $idpName): array {
    // Look up the idp config from your DB, tenant store, etc.
    return [
        'entityId' => '...',
        'singleSignOnService' => ['url' => '...'],
        // ... see config/saml.php for the full shape
    ];
});
```

Calling `Saml::idp($name)->redirect()` resolves through the closure and caches the resulting `SamlAuth` instance.

### Cert and key values

[](#cert-and-key-values)

`x509cert` and `privateKey` accept either inline PEM strings or filesystem paths. Paths can be:

- **Absolute** — `/etc/ssl/certs/saml.crt`
- **Relative to project root** — `storage/certs/saml.crt` (resolved against Laravel's `base_path()`, so it works under php-fpm, queue workers, and scheduled tasks regardless of the current working directory)
- **Relative to PHP's CWD** — works for `php artisan` but not recommended; prefer the project-root form

If a value looks like a path (string, no newlines, ≤4096 chars) but no file is found at either location, `Saml::normalizeConfig()` throws `InvalidConfigException` naming the offending config key.

Usage
-----

[](#usage)

For multi-IdP scenarios, swap any `Saml::method()` call below for `Saml::idp($name)->method()` to target a specific IdP.

### Controller Scaffold

[](#controller-scaffold)

```
php artisan make:controller SamlController
```

```
