PHPackages                             kn4ppster/laravel4-saml2 - 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. kn4ppster/laravel4-saml2

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

kn4ppster/laravel4-saml2
========================

A Laravel 4.2 package for Saml2 integration as a SP (service provider) based on OneLogin toolkit, which is much lightweight than simplesamlphp

0.0.3(9y ago)031.3k↓23.7%3MITPHPPHP &gt;=5.4.0

Since Apr 1Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Kn4ppster/laravel4-saml2)[ Packagist](https://packagist.org/packages/kn4ppster/laravel4-saml2)[ Docs](https://github.com/Kn4ppster/laravel4-saml2/)[ RSS](/packages/kn4ppster-laravel4-saml2/feed)WikiDiscussions laravel-4.2 Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

Laravel 4 - Saml2
-----------------

[](#laravel-4---saml2)

A Laravel package for Saml2 integration as a SP (service provider) based on OneLogin toolkit, which is much lighter and easier to install than simplesamlphp SP. It doesn't need separate routes or session storage to work!

The aim of this library is to be as simple as possible. We won't mess with Laravel users, auth, session... We prefer to limit ourselves to a concrete task. Ask the user to authenticate at the IDP and process the response. Same case for SLO requests.

Installation - Composer
-----------------------

[](#installation---composer)

To install Saml2 as a Composer package to be used with Laravel 4, simply add this to your composer.json:

```
"kn4ppster/laravel4-saml2": "0.0.1"
```

..and run `composer update`. Once it's installed, you can register the service provider in `app/config/app.php` in the `providers` array:

```
'providers' => array(
    		'Kn4ppster\Saml2\Saml2ServiceProvider',
)
```

Then publish the config file with `php artisan config:publish kn4ppster/laravel4-saml2`. This will add the file `app/config/packages/kn4ppster/laravel4-saml2/saml_settings.php`. This config is handled almost directly by [one login](https://github.com/onelogin/php-saml) so you may get further references there, but will cover here what's really necessary.

### Configuration

[](#configuration)

Once you publish your saml\_settings.php to your own files, you need to configure your sp and IDP (remote server). The only real difference between this config and the one that OneLogin uses, is that the SP entityId, assertionConsumerService url and singleLogoutService URL are inyected by the library. They are taken from routes 'saml\_metadata', 'saml\_acs' and 'saml\_sls' respectively.

Remember that you don't need to implement those routes, but you'll need to add them to your IDP configuration. For example, if you use simplesamlphp, add the following to /metadata/sp-remote.php

```
$metadata['http://laravel_url/saml/metadata'] = array(
    'AssertionConsumerService' => 'http://laravel_url/saml/acs',
    'SingleLogoutService' => 'http://laravel_url/saml/sls',
    //the following two affect what the $Saml2user->getUserId() will return
    'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',
    'simplesaml.nameidattribute' => 'uid'
);
```

You can check that metadata if you actually navigate to 'http://laravel\_url/saml/metadata'

### Usage

[](#usage)

When you want your user to login, just call `Saml2Auth::login()`. Just remember that it does not use any session storage, so if you ask it to login it will redirect to the IDP wheather the user is logged in or not. For example, you can change the auth filter.

```
Route::filter('auth', function()
{
	if (Auth::guest())
	{
		return SAML2::login(URL::full()); //url is saved in RelayState

	}
});
```

Only if you want to know, that will redirect the user to the IDP, and will came back to an endpoint the library serves at /saml2/acs. That will process the response and fire an event when is ready. So, next step for you is to handle the response.

```
Event::listen('saml2.loginRequestReceived', function(Saml2User $user)
{
    //$user->getAttributes();
    //$user->getUserId();
    //base64_decode($user->getRawSamlAssertion();
    $laravelUser = //find user by ID or attribute
    //if it does not exist create it and go on  or show an error message
    Auth::login($laravelUser);
});
```

### Log out

[](#log-out)

Now there are two ways the user can log out.

- 1 - By logging out in your app: In this case you 'should' notify the IDP first so it closes global session.
- 2 - By logging out of the global SSO Session. In this case the IDP will notify you on /saml2/slo enpoint (already provided)

For case 1 call `Saml2Auth::logout();` or redirect the user to the route 'saml\_logout' which does just that. Do not close session inmediately as you need to receive a response confirmation from the IDP (redirection). That response will be handled by the library at /saml2/sls and will fire an event for you to complete the operation.

For case 2 you will only receive the event. Both cases 1 and 2 receive the same event.

```
Event::listen('saml2.logoutRequestReceived', function()
{
    Auth::logout();
    //echo "bye, we logged out.";
});
```

That's it. Feel free to ask any questions, make PR or suggestions, or open Issues.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3603d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b1956be3fa0a60b898f70aa421fb45870b5fa1c32b690c3cc6e972f0a1212b0?d=identicon)[Knappster](/maintainers/Knappster)

---

Top Contributors

[![aacotroneo](https://avatars.githubusercontent.com/u/10578291?v=4)](https://github.com/aacotroneo "aacotroneo (14 commits)")[![Kn4ppster](https://avatars.githubusercontent.com/u/7223477?v=4)](https://github.com/Kn4ppster "Kn4ppster (8 commits)")

---

Tags

laravelsamlSAML2onelogin

### Embed Badge

![Health badge](/badges/kn4ppster-laravel4-saml2/health.svg)

```
[![Health](https://phpackages.com/badges/kn4ppster-laravel4-saml2/health.svg)](https://phpackages.com/packages/kn4ppster-laravel4-saml2)
```

###  Alternatives

[aacotroneo/laravel-saml2

A Laravel package for Saml2 integration as a SP (service provider) for multiple IdPs, based on OneLogin toolkit which is much more lightweight than simplesamlphp.

5704.4M](/packages/aacotroneo-laravel-saml2)[scaler-tech/laravel-saml2

SAML2 Service Provider integration for Laravel applications, based on OneLogin toolkit

2737.5k](/packages/scaler-tech-laravel-saml2)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
