<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
samyapp / laravel-external-authentication example snippets
return [
// ... other configuration options
'attributeMap' => [
'username' => 'X-USERNAME',
'role' => 'X-USER-ROLE',
],
'credentialAttributes' => [
'username',
],
'developmentMode' => true,
'developmentAttributes' => [
'X-USERNAME' => 'foo',
'X-USER-ROLE' => 'admin',
// .. any other attributes that would be set by your real auth provider...
]
]
// class EventServiceProvider
/**
* Register any events for your application.
*/
public function boot(): void
{
Event::listen(function (UnknownUserAuthenticating $event) {
$user = new \App\Models\User();
foreach ($event->attributes as $name => $value) {
$user->$name = $value;
}
$user->save();
$event->guard->login($user);
});
}
// class EventServiceProvider
/**
* Register any events for your application.
*/
public function boot(): void
{
Event::listen(function (Illuminate\Auth\Events\Login $event) {
$event->user->save();
});
}