A simple package for using UNC Single Sign On as user authorization for Laravel 5
Laravel UNC SSO is not on Packagist. Add
{
"type": "vcs",
"url": "https://github.com/GlassSteel/laravel-unc-sso"
}
to your composer.json's 'repositories' array, as well as "glasteel/laravel-unc-sso" : "dev-master" in your 'require' array. Then run composer install or composer update.
Then in your config/app.php add
GlassSteel\LaravelUncSso\UncSsoServiceProvider::class
in the providers array. This package automatically registers 'UncSso' as a alias.
Copy the package config to your local config with the publish command:
php artisan vendor:publish
Now generate the package migration:
php artisan unc_sso:migrationIt will generate the <timestamp>_unc_sso_setup_tables.php migration.
You may now run it with the artisan migrate command:
php artisan migrateAfter the migration, two new tables will be present:
unc_keys— stores onyens and unc PIDslocal_users— is used to spoof users in testing
You may also opt to create stub models and a development seed file.
Add $this->call('UncSsoDevUserSetupSeeder'); to DatabaseSeeder.php to use the seeder. You may also need to run composer dump-autoload
Add \GlassSteel\LaravelUncSso\UncInitUser::class to the $middleware array in app/http/Kernel.php to check for a UNC pid on each request, and login the matching user, if any, via Auth::login()
Add 'unc_sso' => \GlassSteel\LaravelUncSso\UncAuthUser::class to the $routeMiddleware array. Any routes protected by the 'unc_sso' middleware will redirect to signup if a valid-seeming PID is found but not mached to an existing user, or will redirect to home if no PID is found.
//Simple test script
echo '<pre style="color:#000">';
print_r(Auth::user()->toArray());
echo '</pre>';