mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Merge pull request #3733 from glmdev/glmdev-ldap-filter
Add config option to specify custom LDAP filter
This commit is contained in:
commit
e2a3aa12a8
21
app/Scopes/LdapFilterScope.php
Normal file
21
app/Scopes/LdapFilterScope.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Scopes;
|
||||||
|
|
||||||
|
use Adldap\Query\Builder;
|
||||||
|
use Adldap\Laravel\Scopes\ScopeInterface;
|
||||||
|
|
||||||
|
class LdapFilterScope implements ScopeInterface {
|
||||||
|
/**
|
||||||
|
* If the ADLDAP_AUTH_FILTER is provided, apply the filter to the LDAP query.
|
||||||
|
* @param Builder $query
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function apply(Builder $query)
|
||||||
|
{
|
||||||
|
$filter = (string) config('ldap_auth.custom_filter');
|
||||||
|
if ( '' !== $filter ) {
|
||||||
|
$query->rawFilter($filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use FireflyIII\Scopes\LdapFilterScope;
|
||||||
|
|
||||||
use Adldap\Laravel\Events\Authenticated;
|
use Adldap\Laravel\Events\Authenticated;
|
||||||
use Adldap\Laravel\Events\AuthenticatedModelTrashed;
|
use Adldap\Laravel\Events\AuthenticatedModelTrashed;
|
||||||
use Adldap\Laravel\Events\AuthenticatedWithWindows;
|
use Adldap\Laravel\Events\AuthenticatedWithWindows;
|
||||||
@ -49,13 +51,17 @@ use Adldap\Laravel\Scopes\UpnScope;
|
|||||||
|
|
||||||
// default OpenLDAP scopes.
|
// default OpenLDAP scopes.
|
||||||
$scopes = [
|
$scopes = [
|
||||||
|
LdapFilterScope::class,
|
||||||
UidScope::class,
|
UidScope::class,
|
||||||
];
|
];
|
||||||
if ('FreeIPA' === env('ADLDAP_CONNECTION_SCHEME')) {
|
if ('FreeIPA' === env('ADLDAP_CONNECTION_SCHEME')) {
|
||||||
$scopes = [];
|
$scopes = [
|
||||||
|
LdapFilterScope::class,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if ('ActiveDirectory' === env('ADLDAP_CONNECTION_SCHEME')) {
|
if ('ActiveDirectory' === env('ADLDAP_CONNECTION_SCHEME')) {
|
||||||
$scopes = [
|
$scopes = [
|
||||||
|
LdapFilterScope::class,
|
||||||
UpnScope::class,
|
UpnScope::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -374,4 +380,16 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Custom LDAP Filter
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value can be optionally provided to restrict LDAP queries to the
|
||||||
|
| given filter. It should be in LDAP filter format, and will be
|
||||||
|
| applied in the LdapFilterScope.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'custom_filter' => env('ADLDAP_AUTH_FILTER', ''),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user