OneLogin SAML Toolkit for Laravel

Overview

OneLogin SAML Toolkit for Laravel

Laravel version of the PHP-SAML Toolkit created by OneLogin

Features

  • Create multiple tenants and authenticate users based on different application permissions.
  • Use Laravel routes to authenticate users with the identity provider.
  • Use php artisan onelogin:create to create different identity routes to use with different applications.

Route locations:

Route::get('/auth/saml/{site_name}', [SAMLAuth::class, 'requestLogin']);
     
Route::get('/auth/saml/{site_name}/metadata', [SAMLAuth::class, 'metadata']);
     
Route::get('/auth/saml/{site_name}/logout', [SAMLAuth::class, 'logout']);
     
Route::post('/auth/saml/{site_name}/consume', [OneLoginController::class, 'consume']);

Setup instructions

Use composer require oliverkuchies/onelogin-toolkit with your Laravel instance.

Add Service Provider to config/app.php

In the providers section of the configuration, add the following:

OneLoginToolkit\OneLoginToolkitServiceProvider::class

This will allow Laravel to register the necessary application files.

Publish package

Use php artisan vendor:publish --provider=OneLoginToolkitServiceProvider - this will publish the necessary files. This includes:

  • A routes file to cater for the SAML authentication routes
  • A config at config/onelogin.php which can be configured to your needs.
  • A model at app/Models/OneLoginSite.php
  • A controller to use for your consuming requests at app/Controllers/OneLoginController.php

You will need to disable CSRF at app/Http/Middleware/VerifyCSRFToken.php by adding the following line to $except: '/auth/saml/*'.

Add Middleware

Add 'onelogin' => \App\Http\Middleware\SAML::class as a middleware in app/Http/Kernel.php.

Passing app parameter to Middleware

When authenticating different apps, be sure to add the app parameter to the middleware.

Don't forget the web route as sessions will need to save, and the web middleware does this by default.

i.e Route::middleware(['onelogin:my_app_name', 'web'])->group(function() {

This will allow you to authenticate multiple apps.

Create your first application!

Use php artisan onelogin:create and follow the prompts.

Please place your certificates in storage/app in a folder of your choice, and be sure to secure them!

When following the prompts you can refer to this certificate relative to storage/app.

You're ready to go!

Congratulations! You're all setup.

To test your application you can try accessing /auth/saml/{yourappname}.

This will redirect you to OneLogin to authenticate your session.

Other tips...

Security information

Please follow instructions at https://github.com/onelogin/php-saml to secure your requests accordingly.

To secure all requests, you can add trusted URLs in config/onelogin.php.

Once that is complete, you can use the following method to secure your requests.

SAMLAuth::isTrustedPrefix(urldecode($url))

This will return true if it is a trusted prefix.

OneLoginController

OneLoginController will be used to consume the authenticated requests within a closure. You can adjust the closure as required.

If you wish to pull parameters from the authenticated request, you will need to adjust your OneLogin settings as follows:

image

You might also like...
PHP package built for Laravel 5.* to easily handle a user email verification and validate the email

jrean/laravel-user-verification is a PHP package built for Laravel 5.* & 6.* & 7.* & 8.* to easily handle a user verification and validate the e-mail.

LDAP Authentication & Management for Laravel

👋 Hey there! Looking for something even easier to use for LDAP integration in your Laravel applications? 🎉 Introducing LdapRecord 🎉 LdapRecord is t

Limit access to your Laravel applications by using invite codes

Doorman Doorman provides a way to limit access to your Laravel applications by using invite codes. Invite Codes: Can be tied to a specific email addre

Declarative style of authorization and validation in laravel.
Declarative style of authorization and validation in laravel.

Laravel Hey Man Readability Counts. In fact, Readability is the primary value of your code !!! 🎀 Heyman continues where the other role-permission pac

Set up Laravel Auth guards using Eloquent in seconds

Nightguard Set up Auth guards using Eloquent in seconds. Introduction Laravel guards provide a super convenient way of authorizing different areas of

Paquete laravel para leer indicadores previsionales desde Previred y tramos de impuesto de 2da categoría desde SII
Paquete laravel para leer indicadores previsionales desde Previred y tramos de impuesto de 2da categoría desde SII

Laravel PreviScraper Indicadores previsionales Chile 🇨🇱 Indicadores previsionales desde Previred y tramos de impuesto desde SII Los datos se obtiene

Laravel starter kit with Livewire & Bootstrap 5 auth scaffolding.

Laravel Livewire Auth Laravel starter kit with Livewire & Bootstrap 5 auth scaffolding. Requirements NPM Installation Create a new Laravel app: larave

Minimalistic token-based authorization for Laravel API endpoints.

Bearer Minimalistic token-based authorization for Laravel API endpoints. Installation You can install the package via Composer: composer require ryang

Library to manage HTTP authentication with PHP. Includes ServiceProviders for easy Laravel integration.

Intervention HttpAuth Library to manage HTTP authentication with PHP. Includes ServiceProviders for easy Laravel integration. Installation You can ins

Comments
  • [IMPR] Routes not RESTful

    [IMPR] Routes not RESTful

    ###What are you trying to improve?

    Routes - they are currently not RESTFUL

    i.e. https://test.com.au/auth/saml/logout/{site_name}

    They should be:

    https://test.com.au/auth/saml/{site_name}/logout

    ###Why are you trying to improve it?

    All routes should be RESTful for easy integration.

    ###What impact will it have on existing users?

    Users will need to update their client route settings.

    enhancement 
    opened by oliverkuchies 1
  • [RELEASE] v1.0.2

    [RELEASE] v1.0.2

    Allow multiple apps to be used by passing parameters to existing middleware.

    Resolve issues with authenticating multiple apps. Users can now add a parameter to identify an app per group.

    opened by oliverkuchies 0
  • [RELEASE] Version 1.0

    [RELEASE] Version 1.0

    • Allow use of onelogin command to create app details
    • Allow use of SAML routes for authentication
    • Allow user to check if user is authenticated.
    • Lots of other groovy features!
    opened by oliverkuchies 0
Releases(v1.0.7.2)
Owner
Oliver Kucharzewski
Software Engineer
Oliver Kucharzewski
A Laravel 5 package for OAuth Social Login/Register implementation using Laravel socialite and (optionally) AdminLTE Laravel package

laravel-social A Laravel 5 package for OAuth Social Login/Register implementation using Laravel socialite and (optionally) AdminLTE Laravel package. I

Sergi Tur Badenas 42 Nov 29, 2022
:octocat: Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, you can easily use it without Laravel.

Socialite Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, You can easily use it in any PHP project. 中文文档 This tool no

安正超 1.2k Dec 22, 2022
An OAuth 2.0 bridge for Laravel and Lumen [DEPRECATED FOR LARAVEL 5.3+]

OAuth 2.0 Server for Laravel (deprecated for Laravel 5.3+) Note: This package is no longer maintaned for Laravel 5.3+ since Laravel now features the P

Luca Degasperi 2.4k Jan 6, 2023
A Simple method to create laravel authentication for an existing laravel project.

Laravel Simple Auth A Simple method to create laravel authentication for an existing laravel project. Indroduction Why I created this kind of package?

Dasun Tharanga 10 Dec 14, 2021
Laravel Auth is a Complete Build of Laravel 8 with Email Registration Verification, Social Authentication, User Roles and Permissions, User Profiles, and Admin restricted user management system.

Laravel Auth is a Complete Build of Laravel 8 with Email Registration Verification, Social Authentication, User Roles and Permissions, User Profiles, and Admin restricted user management system. Built on Bootstrap 4.

Jeremy Kenedy 2.8k Dec 31, 2022
🔐 JSON Web Token Authentication for Laravel & Lumen

Documentation Documentation for 1.* here For version 0.5.* See the WIKI for documentation. Supported by Auth0 If you want to easily add secure authent

Sean Tymon 10.7k Dec 31, 2022
Handle roles and permissions in your Laravel application

Laratrust (Laravel Package) Version Compatibility Laravel Laratrust 8.x 6.x 7.x 6.x 6.x 6.x 5.6.x - 5.8.x 5.2 5.3.x - 5.5.x 5.1 5.0.x - 5.2.x 4.0. Ins

Santiago García 2k Dec 30, 2022
Role-based Permissions for Laravel 5

ENTRUST (Laravel 5 Package) Entrust is a succinct and flexible way to add Role-based Permissions to Laravel 5. If you are looking for the Laravel 4 ve

Zizaco 6.1k Jan 5, 2023
Roles & Permissions for Laravel 8 / 7 / 6 / 5

Defender Defender is an Access Control List (ACL) Solution for Laravel 5 / 6 / 7 (single auth). (Not compatible with multi-auth) With security and usa

Artesãos 437 Dec 22, 2022
Laravel wrapper around OAuth 1 & OAuth 2 libraries.

Introduction Laravel Socialite provides an expressive, fluent interface to OAuth authentication with Facebook, Twitter, Google, LinkedIn, GitHub, GitL

The Laravel Framework 5.2k Dec 27, 2022