DirectoryTree / LdapRecord

A fully-featured LDAP framework.
https://ldaprecord.com
MIT License
500 stars 44 forks source link

ldaprecord v3 basic authentication NoDatabaseUserProvider::getModel() #684

Closed johnfigueroa0 closed 7 months ago

johnfigueroa0 commented 7 months ago

I have used basic ldaprecord authentication in my Laravel 10 project with jetstream (livewire) and it has not worked for me.

I have configured as follows:

`LDAP_LOGGING=true LDAP_CONNECTION=alpha LDAP_CONNECTIONS=alpha

LDAP_ALPHA_HOSTS=192.168.1.100 LDAP_ALPHA_USERNAME="adm@alpha.local" LDAP_ALPHA_PASSWORD="AhdKZLt60ru7M" LDAP_ALPHA_PORT=389 LDAP_ALPHA_BASE_DN="dc=alpha,dc=local" LDAP_ALPHA_TIMEOUT=5 LDAP_ALPHA_SSL=false LDAP_ALPHA_TLS=false LDAP_ALPHA_SASL=false`

My config/auth.php file is configured as follows: `'defaults' => [ 'guard' => 'web', 'passwords' => 'users', ], 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], ],

providers' => [ 'users' => [ 'driver' => 'ldap', 'model' => LdapRecord\Models\ActiveDirectory\User::class, 'rules' => [], 'scopes' => [], ],

],

` The output of the php artisan ldap:test command indicates that the connection is successful: Successful yes. However, when logging in with the ldap credentials I get the following error:

Call to undefined method LdapRecord\Laravel\Auth\NoDatabaseUserProvider::getModel()

What could be happening, will it be necessary to perform any additional configuration?

stevebauman commented 7 months ago

Hi @johnfigueroa0,

Can you please post the entire stack trace of the exception?

johnfigueroa0 commented 7 months ago

hello @stevebauman

Thanks for the guidance, I finally found the request by modifying my authserviceprovider.php

`// app/Providers/AuthServiceProvider.php

// ... use Laravel\Fortify\Fortify; use Illuminate\Support\Facades\Auth;

class AuthServiceProvider extends ServiceProvider { // ...

public function boot()
{
    $this->registerPolicies();

    Fortify::authenticateUsing(function ($request) {
        $validated = Auth::validate([
            'mail' => $request->email,
            'password' => $request->password
        ]);

        return $validated ? Auth::getLastAttempted() : null;
    });
}

}` I followed the instructions indicated in the official documentation:

https://github.com/DirectoryTree/LdapRecord-Docs/blob/master/laravel/v3/auth/plain/laravel-jetstream.md

stevebauman commented 7 months ago

Awesome, glad you were able to resolve the issue 🎉