dev-master
9999999-devLaravel LDAP authentication wrapper
MIT
The Requires
- php >=5.5.9
- illuminate/support 5.3.x|5.4.x|5.5.x|5.6.x
by Didik Tri Susanto
laravel authentication ldap
Laravel LDAP authentication wrapper
Laravel LDAP Authentication is a package for authenticating user to Active Directory using Lightweight Directory Access Protocol and integrated with Laravel authenticatable model out of the box., (*1)
PHP LDAP
ExtensionInstall package through composer., (*2)
composer require ptdot/ldapauth
Next, if using Laravel under 5.5, include the service provider and Facade within your config/app.php
file., (*3)
'providers' => [ Ptdot\LdapAuth\LdapAuthServiceProvider::class, ], 'aliases' => [ 'LdapAuth' => Ptdot\LdapAuth\LdapAuthFacade::class, ]
Since Laravel 5.5+ is using Package Discovery, there is no need manually insert service provider and facade inside your app.php
., (*4)
Publish config using command:, (*5)
php artisan vendor:publish --tag=config
Set keys and values for your LDAP configuration in .env
file., (*6)
LDAP_HOST=ldap.example.com LDAP_PORT=389
Setup your User model or custom authentication model In config/ldap.php
file and don't forget to adjust your usernameField
value from your authentication model., (*7)
Make sure you are already has user data in database and create user model for authentication., (*8)
/* |-------------------------------------------------------------------------- | Authentication user model |-------------------------------------------------------------------------- | | Authentication is used User model for default. | Define this option if authentication model using different model / namespace. | */ 'user' => App\User::class, 'usernameField' => 'username'
For attempting authentication using LDAP:, (*9)
$result = LdapAuth::attempt($username, $password);
Attempt method will return an array that indicate that authentication is success or not., (*10)
Example, (*11)
/** * Logging in using LDAP */ public funtion login(Request $request) { $username = $request->get('username'); $password = $request->get('password'); $login = LdapAuth::attempt($username, $password); if($login['status']) { return "Login success"; } return "Login failed. Error: ".$login['message']; }
Feel free to report an issue or merge request if you want to help this package become better and useful., (*12)
Laravel LDAP authentication wrapper
MIT
laravel authentication ldap