SAML2.0 Service Provider Laravel Package, use this package to log into a IDP with SAML2.0. Please feel free to contribute to this package. This package has had minimal testing, and provides no security guarantees. Use at your own risk.
Via Composer
composer require philwilliammee/samlserviceprovider
Run the migrations
php artisan migrate
Publish Config and Views with
php artisan vendor:publish --provider="PhilWilliammee\SamlServiceProvider\SamlServiceProviderServiceProvider"
Edit the config file in config/samlserviceprovider.php
to your liking.
This package comes with some blade templates that you can use to get you started. You can review them in resources/views/vendor/philwilliammee
example usage:
<x-samlserviceprovider::login redirect="/user">
Login
</x-samlserviceprovider::login>
<x-samlserviceprovider::logout>
Logout
</x-samlserviceprovider::logout>
then in the user controller call:
$session_id = session()->getId();
$user_attributes = SamlServiceProvider::getAttributes($session_id);
You will then probably want to login the user with Laravel, something like this:
$email = $user_attributes['mail'][0];
$name = $user_attributes['displayName'][0];
$user = User::where('email', $email)->first();
if (!$user) {
$user = User::create([
'email' => $email,
'name' => $name,
]);
}
Auth::login($user);
Please see the changelog for more information on what has changed recently.
composer test
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email philwilliammee@gmail.com instead of using the issue tracker.
MIT. Please see the license file for more information.