laravel-doctrine / orm

An integration library for Laravel and Doctrine ORM
MIT License
830 stars 179 forks source link

Authentication user provider [doctrine] is not defined. #615

Open vincent-eleanor-wine opened 2 days ago

vincent-eleanor-wine commented 2 days ago

If you have a question, and not a bug or proposal, post in the discussions. https://github.com/laravel-doctrine/orm/discussions

laravel-doctrine/orm version & Laravel version

laravel-doctrine/orm -> 2.1.0 Laravel Framework 10.48.22

Expected behaviour

the cache was success cached

Actual behaviour

is throwing an error: In CreatesUserProviders.php line 39:
Authentication user provider [doctrine] is not defined.

Steps to reproduce

php8.2 artisan config:cache

TomHAnderson commented 1 day ago

Testing with 3.0 the config:cache works. Are you using this functionality: https://laraveldoctrine.org/docs/1.8/orm/auth ?

Is there more configuration you're not listing here?

TomHAnderson commented 1 day ago

I put together a 2.0 version with your version of Laravel and can't reproduce. I really think you've got configuration somewhere that you haven't listed here.

vincent-eleanor-wine commented 1 day ago

Hi @TomHAnderson , Thank you for your collaboration.

I see that in the above link that you sent above that the structure for driver and model is different from my. should this make the difference? also I do not have created the AuthServiceProvider as Laravel mention in the Documentation.

This as been working for a while like this until this week I have migrated from php8.1 to php8.2 without major migrations.

This is my src/config/auth.php

`<?php

use ...\Core\Entities\User as UserEntity;

return [

/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/

'defaults' => [
    'guard' => 'web',
    'passwords' => 'users',
],

/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session"
|
*/

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],
],

/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/

'providers' => [
    'users' => [
        'driver' => 'doctrine',
        'model' => UserEntity::class,
    ],

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/

'passwords' => [
    'users' => [
        'provider' => 'users',
        'table' => 'password_resets',
        'expire' => 60,
        'throttle' => 60,
    ],
],

/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/

'password_timeout' => 10800,

];`

and the user entity src/src/Api/Core/Entities/User.php:

`use Ramsey\Uuid\Uuid; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableInterface; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordInterface; use Illuminate\Contracts\Auth\MustVerifyEmail as MustVerifyEmailInterface; use LaravelDoctrine\ACL\Contracts\HasPermissions as HasPermissionInterface; use LaravelDoctrine\ACL\Contracts\HasRoles as HasRolesInterface; use LaravelDoctrine\ACL\Roles\HasRoles as HasRolesTrait; use LaravelDoctrine\ACL\Permissions\HasPermissions as HasPermissionsTrait; use LaravelDoctrine\ORM\Notifications\Notifiable as LaravelDoctrineNotifiableTrait; use Illuminate\Notifications\Notifiable as NotifiableTrait; use Illuminate\Database\Eloquent\BroadcastsEvents as BroadcastsEventsTrait; /**

TomHAnderson commented 1 day ago

Thanks @vincent-eleanor-wine . I'm new to administering this project so please work with me to figure this out.

I think duplicating this is key to fixing it. And I think creating a new project that duplicates this bug is the best course of action. Is that something you can do?

TomHAnderson commented 19 hours ago

This is where the doctrine auth provider is configured: https://github.com/laravel-doctrine/orm/blob/3.0.x/src/DoctrineServiceProvider.php#L253-L277