Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lara220120's avatar

Auth driver [auth0] for guard [auth0] is not defined.

# My Environment (Local docker)
"php": "8.2",
"auth0/auth0-php": "^8.10",
 "auth0/login": "^7.8",
"laravel/nova": "4.35",
"spatie/laravel-permission": "^6.0",
"laravel/framework": "11.0",

PROBLEM

Hello, I want to use Auth0 for API routes, as described in the docs. But this error appears, when I want the auth.php configuration:

# api.php
Route::group(['middleware' => ['auth:auth0']], function () {
      Route::get('/getMemberByEmail', 'MemberController@getMemberByEmail');
}
# Error
Auth driver [auth0] for guard [auth0] is not defined.

This post in Auth0 community was not helpful for me.

QUESTION

Do I have register the auth0 driver in Providers/AppServiceProvider or Provider/AuthServiceProvider?

STEPS DONE

# this works!
Route::group(['middleware' => ['auth0.authorize']], function () {
      Route::get('/getMemberByEmail', 'MemberController@getMemberByEmail');
}

So it works with the default middleware auth0.authorize. But I want to use Gates + Policies for preventing broken access control. The problem is that I can't use $this->authorize('accessByEmail', $email);, because there is a conflict between auth0 and spatie/laravel-premissions. So I tried to use a custom UserRepository, as descibed here.

I already have an working Auth0 tenant + application. Auth0 login works fine, so the /config/auth0.php should be fine.

My configuration:

# config/auth.php
// ...
    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'ldap',
        ],
        'auth0' => [
            'driver' => 'auth0',
            'provider' => 'auth0',
        ],
    ],

    'providers' => [
        // ...
        'users' => [
            'driver' =>  'eloquent',
            'model' => App\Models\User::class,
        ],
        'auth0' => [
            'driver' => 'auth0.provider',
            # my custom auth0 user provider
            'repository' => \App\Models\Auth0UserRepository::class,
        ],
    ],

0 likes
0 replies

Please or to participate in this conversation.