laravel-saml2 icon indicating copy to clipboard operation
laravel-saml2 copied to clipboard

ReflectionException (-1) "Class does not exist"

Open xnasa opened this issue 5 years ago • 6 comments

laravel-saml2 : 2.0.0 Laravel 5.8

After initial install and config for the 'test' idp. I tried http://127.0.0.1:8000/saml2/test/metadata and received the error in the title.

In the saml2_settings.php file the following is set as default

     * (Optiona) Which class implements the route functions.
     * If left blank, defaults to this lib's controller (Aacotroneo\Saml2\Http\Controllers\Saml2Controller).
     * If you need to extend Saml2Controller (e.g. to override the `login()` function to pass
     * a `$returnTo` argument), this value allows you to pass your own controller, and have
     * it used in the routes definition.
     */
    'saml2_controller' => '',

If you notice, and this took me a while to see it, there is an extra space in the error message.

"Class  does not exist"

I believe that the controller in the vendor files is not being used. When I did this 'saml2_controller' => 'Aacotroneo\Saml2\Http\Controllers\Saml2Controller', to explicitly use the vendor...src\ file then the route metatdata worked and produced metadata. So it appears that the default, as the config states, is not being used in replacing the empty config file string.

xnasa avatar Aug 02 '19 20:08 xnasa

I'm getting the same error but your fix does not work for me. I'm using: 'saml2_controller' => 'vendor/aacotroneo/laravel-saml2/src/Aacotroneo/Saml2/Http/Controllers/Saml2Controller',

lloydie-t avatar Aug 10 '19 05:08 lloydie-t

@lloydie-t : For me it also worked to just comment it out:

    // 'saml2_controller' => '',

danmichaelo avatar Aug 14 '19 15:08 danmichaelo

@lloydie-t

According to the readme you should be passing your controller's fully qualified namespace:

'saml2_controller' => 'App\Http\Controllers\MyNamespace\MySaml2Controller' not a file reference.

so, in my specific usecase, I had a controller file /app/Http/Controllers/CustomAuth/SabaAuth.php that had a namespace of App\Http\Controllers\CustomAuth\SabaAuth

So my setting is: 'saml2_controller' => 'App\Http\Controllers\CustomAuth\SabaAuth',

And it works perfectly.

+1 to @xnasa for opening this, as the default beahvior of blank will cause this error out of the box.

christopherarter avatar Aug 28 '19 15:08 christopherarter

@xnasa I am using 'saml2_controller' => 'Aacotroneo\Saml2\Http\Controllers\Saml2Controller', but still getting same error..

rachit0312 avatar Sep 25 '19 14:09 rachit0312

@xnasa I am using 'saml2_controller' => 'Aacotroneo\Saml2\Http\Controllers\Saml2Controller', but still getting same error..

Above issue has been fixed on server but still on my local system.

getting new issue Route [saml_login] not defined. (View: C:\xampp\htdocs\cfxproduct\resources\views\auth\login.blade.php)

rachit0312 avatar Sep 25 '19 15:09 rachit0312

i got Class saml does not exist it was because i forgot to add saml to the $middlewareGroups in Kernel.php

bm2ilabs avatar Dec 23 '19 09:12 bm2ilabs