aacotroneo / laravel-saml2

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

route:list produces 404 from the Saml2Controller #193

Closed xnasa closed 5 years ago

xnasa commented 5 years ago

laravel_saml2 : 2.0.0 Laravel 5.8

The application routes used in the url seem to work correctly however the command

php artisan route:list

produces and error with a 404 exception.

$ php artisan route:list

   Symfony\Component\HttpKernel\Exception\NotFoundHttpException  :

  at {_project path_}\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:992
    988|      */
    989|     public function abort($code, $message = '', array $headers = [])
    990|     {
    991|         if ($code == 404) {
  > 992|             throw new NotFoundHttpException($message);
    993|         }
    994|
    995|         throw new HttpException($code, $message, null, $headers);
    996|     }

  Exception trace:

  1   Illuminate\Foundation\Application::abort("", [])
      {_project path_}\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php:46

  2   abort()
      {_project path_}\vendor\aacotroneo\laravel-saml2\src\Aacotroneo\Saml2\Http\Controllers\Saml2Controller.php:24

It appears that the Saml2Controller evaluates to false when the command 'php artisan route:list' tries to produce information on the routes. Other than that the controller operates the route in the web interface just fine.

LauLogisch commented 5 years ago

Same issue.

Just a workaround would be to add this to the Saml2Controler.php:23

 if (app()->runningInConsole()) {
     $idpName = config('saml2_settings.idpNames')[0];          
}
aloha commented 5 years ago

+1 on the 404. It'd be a better fix if it didn't need request parameters within the class constructor and instead looked to inject dependencies using Laravel's IoC.

danmichaelo commented 5 years ago

Agree. In general, I think it's best to avoid constructors in controllers altogether if possible.