Ldaprecord with filament
Has anyone implemented ldaprecord with filament? I have created a page, I have overridden the default login to use username instead of email, i had implemented ldap record in the app before i installed filament and it was working fine, so how can i tell filament to use ldap, i have tried to implement LdapAuthenticatable on the custom Login but it still says credentials dont match our records
12 Replies
Not sure how your LDAP implementation works. You can change the auth guard which Filament uses
user model 'class User extends Authenticatable implements LdapAuthenticatable'
in auth.php i changed the guard to 'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'ldap',
],
],
under providers
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'ldap' => [
'driver' => 'ldap',
'model' => LdapRecord\Models\ActiveDirectory\User::class,
'rules' => [],
'database' => [
'model' => App\Models\User::class,
'sync_passwords' => true,
'sync_attributes' => [
'name' => 'cn',
'email' => 'mail',
'username' => 'samaccountname',
],
'sync_existing' => [
'email' => 'mail',
],
'password_column' => 'password',
],
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
Basically i use username and the guard is ldap
I'm also looking for the same possibility:
https://ldaprecord.com/ this has an extensive documentation for Jetstream, Breeze.
It would be great if some documentation is extended from filament core team
LdapRecord
LdapRecord is a framework that helps you quickly integrate LDAP into your PHP applications.
Did one of you get this to work?
I got this working
Legend! Needed this tomorrow for a project
I then added Login class in AdminPanelProvider.php
How are you syncing the user to Filament from LDAP?
in my auth.php
I edited FortifyServiceProvider.php in providers like this since am using jetstream and fortify
the User.php model is like this
I'm using email instead of username as I wanted both local and LDAP auth. I got this working similar to above, just replacing the getCredentialsFromFormData function, however I tried to do with fallback (as is done with Fortify, etc) but it's not working as expected. Local auth just doesn't work. Any thoughts as to why fallback doesn't work here?
Hmm, never mind... it appears my migrations weren't updating users table correctly. After dropping and re-creating I can now login with username or email (ldap or local). I've modified my custom Login class (similar to @kenro's setup), see next reply. Specifically Filament::auth()->attempt() is using the getCredentialsFromFormData, with logic to determine if username or email, and I added the 'tabindex' on the username field as it was skipping the password field when tabbing over.
Many thanks to @kenro for your post putting me on the right direction!!
in providers -> ldap -> model, don't forget to use
when using Online LDAP test server or any other OpenLDAP.
source: https://www.youtube.com/watch?v=5lRBGdLrxj0
Abdelhalim Saïdi
YouTube
Step 2 : Database auth - install and config - Ldaprecord v2 - larav...
Now we should create and connect our database than test it and we will leave the chapter of Laravel breeze at the last video
@kenro Thanks for the hint with the auth.php. I got it working with Laravel 11, ldaprecprd 3 and filament 3