Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vincent-eleanor-wine opened this issue Oct 24, 2024 · 5 comments
Open

Comments

@vincent-eleanor-wine
Copy link

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
Copy link
Contributor

TomHAnderson commented Oct 24, 2024

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
Copy link
Contributor

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
Copy link
Author

vincent-eleanor-wine commented Oct 24, 2024

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;
/**

  • @Orm\Entity
  • @Orm\Table(name="users")
    */
    class User implements AuthenticatableInterface, CanResetPasswordInterface, MustVerifyEmailInterface, HasPermissionInterface, HasRolesInterface
    {
    use Timestamps;
    use UserAuthenticationTrait;
    use AuthorizationTrait;
    use HasRolesTrait;
    use HasPermissionsTrait;
    use LaravelDoctrineNotifiableTrait;
    use BroadcastsEventsTrait;
    use NotifiableTrait;`

@TomHAnderson
Copy link
Contributor

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants