aacotroneo / laravel-saml2

A Laravel 5 package for Saml2 integration as a SP (service provider) based on the simple OneLogin toolkit
MIT License
564 stars 237 forks source link

Should we disable the Auth::routes(); in routes/web.php #228

Open grharon opened 4 years ago

grharon commented 4 years ago

Hello,

I would like to convert the current authentication project to use saml2 and I am still in the learning process to do it.

The Routes:Auth is using middleware Auth, so we will no longer be using that. However when i add function handle in App/Http/Middleware/RedirectIfAuthenticated.php i got error message:

Symfony\Component\Routing\Exception\RouteNotFoundException Route [login] not defined.

This is code for web.php //Auth::routes(); Route::get('/home', 'HomeController@index')->name('home');

This is code RedirectIfAuthenticated.php code as per suggested use Aacotroneo\Saml2\Saml2Auth;

public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { return redirect('/home'); }

    if (Auth::guest())
    {
        if ($request->ajax())
        {
            return response('Unauthorized.', 401);
        }
        else
        {
            $saml2Auth = new Saml2Auth(Saml2Auth::loadOneLoginAuthFromIpdConfig('sso'));
            return $saml2Auth->login(URL::full());
        }
    }

    return $next($request);
}

Shoud we turn off the auth mddleware and how we should go about it?

Any idea? Thanks

grharon commented 4 years ago

Found it, the HomeController constructed with middleware auth. So i changed it to saml to solve the issue.