Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit b71f1de

Browse files
committed
Added ability to select certain attributes for authentication and binding
- Closes #14
1 parent a72f4d7 commit b71f1de

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

src/AdldapAuthUserProvider.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function retrieveByToken($identifier, $token)
3838
public function retrieveByCredentials(array $credentials)
3939
{
4040
// Get the search query for users only
41-
$query = Adldap::users()->search();
41+
$query = $this->newAdldapUserQuery();
4242

4343
// Get the username input attributes
4444
$attributes = $this->getUsernameAttribute();
@@ -164,7 +164,7 @@ protected function discoverAdldapFromModel($model)
164164

165165
$key = key($attributes);
166166

167-
$query = Adldap::users()->search();
167+
$query = $this->newAdldapUserQuery();
168168

169169
$query->whereEquals($attributes[$key], $model->{$key});
170170

@@ -194,6 +194,16 @@ protected function bindAdldapToModel(User $user, Authenticatable $model)
194194
return $model;
195195
}
196196

197+
/**
198+
* Returns a new Adldap user query.
199+
*
200+
* @return \Adldap\Query\Builder
201+
*/
202+
protected function newAdldapUserQuery()
203+
{
204+
return Adldap::users()->select($this->getSelectAttributes())->search();
205+
}
206+
197207
/**
198208
* Authenticates a user against Active Directory.
199209
*
@@ -248,4 +258,15 @@ protected function getSyncAttributes()
248258
{
249259
return Config::get('adldap_auth.sync_attributes', ['name' => ActiveDirectory::COMMON_NAME]);
250260
}
261+
262+
/**
263+
* Retrieves the Aldldap select attributes when performing
264+
* queries for authentication and binding for users.
265+
*
266+
* @return array
267+
*/
268+
protected function getSelectAttributes()
269+
{
270+
return Config::get('adldap_auth.select_attributes', []);
271+
}
251272
}

src/Config/auth.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,22 @@
7878

7979
],
8080

81+
/*
82+
|--------------------------------------------------------------------------
83+
| Select Attributes
84+
|--------------------------------------------------------------------------
85+
|
86+
| Attributes to select upon the user on authentication and binding.
87+
|
88+
| If no attributes are given inside the array, all attributes on the
89+
| user are selected.
90+
|
91+
*/
92+
93+
'select_attributes' => [
94+
95+
//
96+
97+
],
98+
8199
];

0 commit comments

Comments
 (0)