diff --git a/.env.example b/.env.example index 415321c6..108283ff 100644 --- a/.env.example +++ b/.env.example @@ -15,4 +15,4 @@ LDAP_HOST= LDAP_BASE_DN= LDAP_USERNAME= LDAP_PASSWORD= -LDAP_CACHE=true +LDAP_CACHE=false diff --git a/app/Classes/LDAP/Server.php b/app/Classes/LDAP/Server.php index 239e8d9f..eda357f5 100644 --- a/app/Classes/LDAP/Server.php +++ b/app/Classes/LDAP/Server.php @@ -181,12 +181,6 @@ final class Server if (! $objects) return collect($base->namingcontexts); - /** - * @note While we are caching our baseDNs, it seems if we have more than 1, - * our caching doesnt generate a hit on a subsequent call to this function (before the cache expires). - * IE: If we have 5 baseDNs, it takes 5 calls to this function to cache them all. - * @todo Possibly a bug with ldaprecord, so need to investigate - */ $result = collect(); foreach ($base->namingcontexts as $dn) $result->push((new Entry)->cache($cachetime)->findOrFail($dn)); diff --git a/app/Http/Middleware/SwapinAuthUser.php b/app/Http/Middleware/SwapinAuthUser.php index e7c24e06..d69eb814 100644 --- a/app/Http/Middleware/SwapinAuthUser.php +++ b/app/Http/Middleware/SwapinAuthUser.php @@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Session; use LdapRecord\Container; -use App\Ldap\Connection; +use App\Ldap\Guard; class SwapinAuthUser { @@ -37,7 +37,11 @@ class SwapinAuthUser } // We need to override our Connection object so that we can store and retrieve the logged in user and swap out the credentials to use them. - Container::getInstance()->addConnection(new Connection(config('ldap.connections.'.$key)),$key); + $c = Container::getInstance() + ->getConnection($key); + + $c->setConfiguration(config('ldap.connections.'.$key)); + $c->setGuardResolver(fn()=>new Guard($c->getLdapConnection(),$c->getConfiguration())); return $next($request); } diff --git a/app/Ldap/Connection.php b/app/Ldap/Connection.php deleted file mode 100644 index c9c25b96..00000000 --- a/app/Ldap/Connection.php +++ /dev/null @@ -1,21 +0,0 @@ -authGuardResolver = function () { - return new Guard($this->ldap, $this->configuration); - }; - } -} \ No newline at end of file