PHPackages                             basvanh/simplesaml - 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. basvanh/simplesaml

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

basvanh/simplesaml
==================

This package provides a wrapper to onelogin/php-saml library.

013PHP

Since Aug 15Pushed 6y ago1 watchersCompare

[ Source](https://github.com/BasvanH/simplesaml)[ Packagist](https://packagist.org/packages/basvanh/simplesaml)[ RSS](/packages/basvanh-simplesaml/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel 5.5 - Saml2
-------------------

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

This package offers Saml2 integration as a Service Provider. It uses [OneLogin](https://github.com/onelogin/php-saml) APIs to connect with IPD and retreive parsed data. The code was tested on Laravel Homestead Virtual machine with PHP 7.1 and Laravel 5.5.28.

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

[](#installation)

You can install this project using composer command

```
composer require BasvanH/simplesaml

```

Laravel Configuration
---------------------

[](#laravel-configuration)

You need to update the below code to execute this package

1. First make sure you run the `php artisan vendor:publish` command. This command will copy the `saml2_settings.php` file to config folder.
2. Next, you want to update settings inside this folder or add environment variables to .env file for idp\_host, sp\_entityid, ipd\_entityid, and idp\_x509. Here are the sample settings:

```
    #SAML2 Settings
    SAML2_IDP_HOST=https://developer.oktapreview.com
    SAML2_SP_ENTITYID=myapp
    SAML2_IDP_URI="/saml2/idp/ssoservice.php"
    SAML2_IDP_ENTITYID=http://www.okta.com/exkd9nlyw4oshZ4U80h8
    SAML2_IDP_x509="..."

```

3. Update `config\app.php` with the following:

```
    'aliases' => [
        ....
        'Saml2' => BasvanH\SimpleSaml\Facades\Saml2Auth::class,
    ];
    'providers' => [
        ....
        BasvanH\SimpleSaml\Providers\SimpleSamlServiceProvider::class,
    ];
```

4. Inside the `Kernel.php`, you would want to setup few things for saml to work as follows: Update middlewaregroup block:

```
        protected $middlewareGroups = [
            .....
            'saml2group' => [
                \App\Http\Middleware\EncryptCookies::class,
                \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
                \Illuminate\Session\Middleware\StartSession::class,
                \Illuminate\View\Middleware\ShareErrorsFromSession::class,
                \Illuminate\Routing\Middleware\SubstituteBindings::class,
            ],
        ];
    Also, add the following line to the routeMiddleware block:
        protected $routeMiddleware = [
            ....
            'saml2' => \BasvanH\SimpleSaml\Middleware\Saml2Middleware::class,
        ];
```

5. Update `EventServiceProvider.php` with the following:

```
    protected $listen = [
            ....
            'BasvanH\SimpleSaml\Events\Saml2LoginEvent' => [
                'App\Listeners\UserLoggedIn'],
        ];
```

6. Finally, create Listener class inside /Listeners folder as follows:

```
