nusait / nu-auth
There is no license information available for the latest version (3.1.2) of this package.
3.1.2
2015-12-10 19:46 UTC
Requires
- php: >=5.3.0
- illuminate/auth: ~5.0
- illuminate/contracts: ~5.0
- illuminate/support: ~5.0
- nusait/nuldap: ~2.1
README
This is a package created for Authentication at NUSAIT. (Other people can use it, but it is pretty specific for our own use)
Install
- run
composer require nusait/nu-auth
- add in
app
configuration file's service providers:Nusait\NuAuth\NuAuthServiceProvider::class
- you can run
php artisan vendor:publish
. You should see two files being copied to your config directory:nuauth.php
andldap.php
. Take a look atldap.php
to see what you need to put in your .env file. - change
auth
configuration's driver to "nuauth"
To Use
- just run "Auth::attempt" like normal. :D Happy Time
Advanced
Sometimes you want to have a more flexible way of creating your user. Maybe you want to include the user's emplid when you save it to the database. You can set the "userCreator" config property as a callback as such
[... 'userCreator' => function ($user, $metadata, $ldap) { // $user is the laravel model. // $metadata is the raw metadata from ldap. // $ldap is the \Nusait\NuLdap\Ldap object. $user->first_name = $metadata['given_name'][0]; $user->last_name = $metadata['sn'][0]; $user->emplid = $metadata['uid'][0]; $user->save(); //remember to return the $user return $user; }; ]