laravel-enso / enso

Laravel Vue SPA, Bulma themed. For demo login use `admin@laravel-enso.com` & `password` -
https://www.laravel-enso.com
MIT License
1.08k stars 277 forks source link

SSO auth option (SAML) #377

Closed robbykrlos closed 3 years ago

robbykrlos commented 3 years ago

This is a feature request.

We are starting implementing a new login option using simpleSAMLphp for SSO (Single Sign On). We were wondering if you consider this in the future, or you have already support for such login option.

If you are interested, I can change my implementation so it goes in the same direction with your vision, so later we will PR for everyone.

Just an idea...

mauthi commented 3 years ago

+1

robbykrlos commented 3 years ago

OK, so if this is not needed here's how I did / will do (still in progress) this:

image

app/Providers/EventServiceProvider.php:

protected $listen = [
        'Aacotroneo\Saml2\Events\Saml2LoginEvent' => [
            'App\Listeners\Saml2LoginListener',
        ],
    ];

image (the only part altered is the yellow part, where "wac" is my {IdPName})


Code flow:

  1. User loads the login page.
  2. User presses the SSO Login
  3. A redirect is made to {routesPrefix}/{idpName}/login - which redirects to IdP and login is requested there.
  4. After user sucessfuly logs in at IdP, it is redirected back to {routesPrefix}/{idpName}/acs which raises an event Aacotroneo\Saml2\Events\Saml2LoginEvent.
  5. Inside the Event listener, we read data from IdP, validate it, and if valid, redirect to loginsso/encrpted_data
  6. Enso login page is loaded again, but since the loginsso route loads the same Login component, we can disable validation of username/password, set a flag that this is sso login, and forward the data to the login controller.
  7. Force submit.
  8. Login component will call the api/login endpoint that will use LoginController to handle the request.
  9. Override local LoginController will handle sso case based on found token.
  10. Normal login will be granted.