Currently I have two levels of user in my app. A standard user, which uses a Laravel's built-in database authentication; and an administrative user, which uses LDAP authentication via Adldap2.
config/auth.php
:
...
"guards" => [
"web" => [
"driver" => "session",
"provider" => "users",
],
"admin" => [
"driver" => "session",
"provider" => "admins",
],
"providers" => [
"users" => [
"driver" => "eloquent",
"model" => App\User::class,
],
"admins" => [
"driver" => "ldap",
"model" => App\Admin::class,
],
],
...
No problems with this setup at all.
Now, there is the possibility of having administrative users from outside the company. These users would not be authenticated by LDAP, but from a database record in a new admins
table. I could set up a third provider, but obviously going into the app and rewriting everywhere permissions are checked would not be fun, so I'm hoping there's another way.
Assuming that we had LDAP users login with an LDAP domain, e.g. username@corp.internal
, is there a way to change the driver from "ldap" to "eleoquent" based on the provided user name?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire