dfoxx / laravel-shibboleth by dfoxx

41
2
1
Package Data
Maintainer Username: dfoxx
Maintainer Contact: david@dfoxx.com (David F. Sterling)
Package Create Date: 2017-02-07
Package Last Update: 2019-07-24
Language: PHP
License: MIT
Last Refreshed: 2024-11-14 15:06:49
Package Statistics
Total Downloads: 41
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 1
Total Forks: 2
Total Open Issues: 2

NC State Shibboleth for Laravel

This package is provide some basic guidance on setting up authentication middleware, custom guard, and user provider for Shibboleth in Laravel 5.4, 5.5.

Install

Via Composer

$ composer require dfoxx/laravel-shibboleth

Then add the service provider in config/app.php:

Dfoxx\Shibboleth\ShibbolethServiceProvider::class,

You must add the unity_id to the $fillable array in app/User.php:

protected $fillable = [
        'unity_id', 'name', 'email',
];

You must specify the identifier on the User model by adding the following to app/User.php:

    /**
     * Get the name of the unique identifier for the user.
     *
     * @return string
     */
    public function getAuthIdentifierName()
    {
        return 'unity_id';
    }

    /**
     * Get the unique identifier for the user.
     *
     * @return mixed
     */
    public function getAuthIdentifier()
    {
        return $this->unity_id;
    }

Edit config/auth.php:

'guards' => [
        'web' => [
            'driver' => 'shibboleth',
            'provider' => 'users',
        ],
],

'providers' => [
        'users' => [
            'driver' => 'shibboleth',
            'model' => App\User::class,
        ],
],

Add default user for testing to config/services.php:

'shib' => [
    'default_user' => env('APP_USER')
],

Note: Because we are using Laravel's config caching, you will need to run php artisan config:cache in order to reflect the change in config/services.php

Add middleware to the app/Http/Kernel.php:

'auth.shib' => \Dfoxx\Shibboleth\AuthenticateWithShibboleth::class,

Usage

When the app environment is set to local APP_ENV=local in .env can add the value APP_USER=userid to specify which user you want to log in as.

To configure routes that use the middleware see this example:

Route::group(['middleware' => 'auth.shib'], function() {

    Route::get('/home', 'HomeController@index');

});

License

The MIT License (MIT). Please see License File for more information.