You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 24, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: docs/auth/setup.md
+46-9Lines changed: 46 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -271,11 +271,7 @@ All other users will be denied authentication, even if their credentials are val
271
271
272
272
## Usernames
273
273
274
-
Inside your `config/ldap_auth.php` file there is a configuration option named `usernames`.
275
-
276
-
This array contains the `ldap` attributes you use for authenticating users, as well as the `eloquent` attribute for locating the LDAP users local model.
277
-
278
-
You can ignore the `windows` configuration array, unless you're planning on using the included [middleware](middleware.md) for single sign on authentication.
274
+
Inside your `config/ldap_auth.php` file there is a configuration option named `usernames`:
279
275
280
276
```php
281
277
'usernames' => [
@@ -295,7 +291,51 @@ You can ignore the `windows` configuration array, unless you're planning on usin
295
291
],
296
292
```
297
293
298
-
If you're using a `username` field instead of `email` in your application, you will need to change this configuration.
294
+
Let's go through each option with their meaning.
295
+
296
+
### LDAP
297
+
298
+
The LDAP array contains two elements each with a key and value.
299
+
300
+
The `discover` key contains the LDAP users attribute you would like your authenticating users to be located by.
301
+
302
+
> **Note**: If you're using the `NoDatabaseUserProvider` it is extremely important to know that this value is used as the key to retrieve the inputted username from the `Auth::attempt()` credentials array.
303
+
>
304
+
> For example, if you're executing an `Auth::attempt(['username' => 'jdoe..'])` and you have a `discover` value set to `userprincipalname` then the Adldap2-Laravel auth driver will try to retrieve your users username from the given credentials array with the key `userprincipalname`. This would generate an exception since this key does not exist in the above credentials array.
Will try to locate a user in your LDAP directory with a `userprincipalname` equal to `jdoe@corp.com`. Then, when an LDAP record of this user is located, their `disintinguishedname` will be retrieved from this record, an be passed into an `Adldap\Auth\Guard::attempt()` (ex `Guard::attempt('cn=John Doe,ou=Users,dc=corp,dc=com', 'password')`).
325
+
326
+
> **Note**: It's **extremely** important to know that your configured `account_suffix` and `account_prefix` (located in your `config/ldap.php` file) will be appended or prepended *onto* this passed in username.
327
+
328
+
You can ignore the `windows` configuration array, unless you're planning on using the included [middleware](middleware.md) for single sign on authentication.
329
+
330
+
### Eloquent
331
+
332
+
The eloquent key contains a value that should match the username column you have set up in your `users` database table.
333
+
334
+
For example, if you're using a `username` field instead of `email` in your application, you will need to change this option to `username`.
335
+
336
+
> **Note**: If you're using the `DatabaseUserProvider` it is extremely important to know that this value is used as the key to retrieve the inputted username from the `Auth::attempt()` credentials array.
337
+
>
338
+
> For example, if you're executing an `Auth::attempt(['username' => 'jdoe..'])` and you have an `eloquent` value set to `email` then the Adldap2-Laravel auth driver will try to retrieve your users username from the given credentials array with the key `email`. This would generate an exception since this key does not exist in the above credentials array.
299
339
300
340
> **Note**: Keep in mind you will also need to update your `database/migrations/2014_10_12_000000_create_users_table.php`
301
341
> migration to use a username field instead of email, **as well as** your LoginController.
@@ -306,11 +346,8 @@ For example, if you'd like to login users by their `samaccountname`:
306
346
'usernames' => [
307
347
308
348
'ldap' => [
309
-
310
349
'discover' => 'samaccountname', // Changed from `userprincipalname`
0 commit comments