* remove twitter link * remove WIP file * adjust release draft message * reset code coverage threshold back to 0.5 * changed wordings * re-activate wizard for fixture accounts * fix repo url and license * license identifier * bump version * moved Kimai 1 import command from core to plugin * do not traverse into invoice template subdirectories (#3735) * fix branch alias * composer update * switch language on wizard select * new twig function to create qr code * fix daily stats in timesheet listing * improved html invoice templates
81 lines
2.5 KiB
PHP
81 lines
2.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Kimai time-tracking app.
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace App\Security;
|
|
|
|
use App\Configuration\SystemConfiguration;
|
|
use App\Entity\User;
|
|
use App\Ldap\LdapUserProvider;
|
|
use Symfony\Component\Security\Core\User\ChainUserProvider;
|
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
|
|
|
/**
|
|
* @template-implements PasswordUpgraderInterface<User>
|
|
*/
|
|
final class KimaiUserProvider implements UserProviderInterface, PasswordUpgraderInterface
|
|
{
|
|
private ?ChainUserProvider $provider = null;
|
|
|
|
/**
|
|
* @param iterable|UserProviderInterface[] $providers
|
|
*/
|
|
public function __construct(private iterable $providers, private SystemConfiguration $configuration)
|
|
{
|
|
}
|
|
|
|
private function getInternalProvider(): ChainUserProvider
|
|
{
|
|
if ($this->provider === null) {
|
|
$activated = [];
|
|
foreach ($this->providers as $provider) {
|
|
if ($provider instanceof LdapUserProvider) {
|
|
if (!class_exists('Laminas\Ldap\Ldap')) {
|
|
continue;
|
|
}
|
|
if (!$this->configuration->isLdapActive()) {
|
|
continue;
|
|
}
|
|
}
|
|
$activated[] = $provider;
|
|
}
|
|
$this->provider = new ChainUserProvider(new \ArrayIterator($activated));
|
|
}
|
|
|
|
return $this->provider;
|
|
}
|
|
|
|
public function getProviders(): array
|
|
{
|
|
return $this->getInternalProvider()->getProviders();
|
|
}
|
|
|
|
public function loadUserByIdentifier(string $identifier): UserInterface
|
|
{
|
|
return $this->getInternalProvider()->loadUserByIdentifier($identifier);
|
|
}
|
|
|
|
public function refreshUser(UserInterface $user): UserInterface
|
|
{
|
|
return $this->getInternalProvider()->refreshUser($user);
|
|
}
|
|
|
|
public function supportsClass(string $class): bool
|
|
{
|
|
return $this->getInternalProvider()->supportsClass($class);
|
|
}
|
|
|
|
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
|
|
{
|
|
$this->getInternalProvider()->upgradePassword($user, $newHashedPassword);
|
|
}
|
|
}
|