Skip to content

philwilliammee/samlserviceprovider

Repository files navigation

SamlServiceProvider

Latest Version on Packagist Total Downloads

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.

Installation

Via Composer

composer require philwilliammee/samlserviceprovider

Usage

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);

Change log

Please see the changelog for more information on what has changed recently.

Testing

composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email philwilliammee@gmail.com instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published