Skip to content

Commit

Permalink
Allow defining own LDAP query
Browse files Browse the repository at this point in the history
  • Loading branch information
Daynnnnn committed Sep 18, 2024
1 parent 4ed3a46 commit 0efca7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/forward-authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
'username' => env('STATAMIC_FORWARD_AUTH_BIND_USERNAME'),

'password' => env('STATAMIC_FORWARD_AUTH_BIND_PASSWORD'),

'queryCallback' => fn ($connection, $credentials) => $connection->query()->where('mail', '=', $credentials['email'])->first(),
],

],
Expand Down
2 changes: 1 addition & 1 deletion src/AuthServices/LdapAuthService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function checkCredentialsAgainstForwardAuth(array $credentials): array|fa
// end block with finally for the same reason.
try {
// Search for user with user provided email
$user = $mainConnection->query()->where('mail', '=', $credentials['email'])->first();
$user = $this->config['queryCallback']($mainConnection, $credentials);

// Try connect to the LDAP provider with found users DN and provided password
$userConnection = new Connection([
Expand Down

0 comments on commit 0efca7c

Please sign in to comment.