Database Sync Auth on certain email domains #253
-
Is there a way to only hit the LDAP server if the email is from a certain domain? For example a user from compayldap.com i want to hit the ldap server but a user that is from company2.com i want normal auth straight from the database. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @jmurphy45, You will have to configure two authentication guards (inside of your The built-in LdapRecord-Laravel auth database driver only supports fallback when a user cannot be found in the directory, and does not allow for custom conditions. https://ldaprecord.com/docs/laravel/v2/auth/database/laravel-breeze/#fallback-authentication |
Beta Was this translation helpful? Give feedback.
Hi @jmurphy45,
You will have to configure two authentication guards (inside of your
config/auth.php
file -- one for LDAP auth and one for Eloquent auth), and then swap them depending on the user submitted email usingAuth::shouldUse($guard)
.The built-in LdapRecord-Laravel auth database driver only supports fallback when a user cannot be found in the directory, and does not allow for custom conditions.
https://ldaprecord.com/docs/laravel/v2/auth/database/laravel-breeze/#fallback-authentication