PHP code example of lukasmu / laravel-samlite

1. Go to this page and download the library: Download lukasmu/laravel-samlite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lukasmu / laravel-samlite example snippets




namespace App\Http\Controllers;

use LukasMu\Samlite\Http\Controllers\SamlController;
use LukasMu\Samlite\SamlAuth;

class AuthenticationController extends SamlController
{
    
    public function loginUser(SamlAuth $saml_auth)
    {
        $mail = $saml_auth->getAttribute('http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress')[0];
        $name = $saml_auth->getAttribute('http://schemas.xmlsoap.org/ws/2005/05/identity/claims/displayname')[0];
        $user = User::where('email', $mail)->first();
        if (!$user) {
            $user = new User;
            $user->name = $name;
            $user->email = $mail;
            $user->password = md5(rand(1,10000));
            $user->save();
        }
        $this->guard()->loginUsingId($user->id);
    }

}
bash
php artisan saml:setup
bash
php artisan vendor:publish --provider="LukasMu\Samlite\SamlServiceProvider" --tag="config"