mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 08:35:00 +00:00
Update configuration to comply with symfony 7.2
This commit is contained in:
@@ -22,7 +22,7 @@ use function is_int;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_activity');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -16,7 +16,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_aside_activity');
|
||||
|
||||
|
@@ -16,7 +16,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_budget');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -21,7 +21,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_calendar');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -22,7 +22,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_custom_fields');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -16,7 +16,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_doc_generator');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:doc-store:configure-openstack')]
|
||||
class ConfigureOpenstackObjectStorageCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Configure openstack container to store documents';
|
||||
@@ -39,7 +40,6 @@ class ConfigureOpenstackObjectStorageCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('chill:doc-store:configure-openstack')
|
||||
->addOption('os_token', 'o', InputOption::VALUE_REQUIRED, 'Openstack token')
|
||||
->addOption('domain', 'd', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Domain name')
|
||||
;
|
||||
|
@@ -22,7 +22,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_doc_store');
|
||||
/** @var ArrayNodeDefinition $rootNode */
|
||||
|
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocStoreBundle\Security\Authenticator;
|
||||
|
||||
use Lexik\Bundle\JWTAuthenticationBundle\TokenExtractor\TokenExtractorInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Extract the JWT Token from the segment of the dav endpoints.
|
||||
*
|
||||
* A segment is a separation inside the string, using the character "/".
|
||||
*
|
||||
* For recognizing the JWT, the first segment must be "dav", and the second one must be
|
||||
* the JWT endpoint.
|
||||
*/
|
||||
final readonly class DavOnUrlTokenExtractor implements TokenExtractorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
) {}
|
||||
|
||||
public function extract(Request $request): false|string
|
||||
{
|
||||
$uri = $request->getRequestUri();
|
||||
|
||||
$segments = array_values(
|
||||
array_filter(
|
||||
explode('/', $uri),
|
||||
fn ($item) => '' !== trim($item)
|
||||
)
|
||||
);
|
||||
|
||||
if (2 > count($segments)) {
|
||||
$this->logger->info('not enough segment for parsing URL');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('dav' !== $segments[0]) {
|
||||
$this->logger->info('the first segment of the url must be DAV');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $segments[1];
|
||||
}
|
||||
}
|
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocStoreBundle\Security\Authenticator;
|
||||
|
||||
use Chill\DocStoreBundle\Security\Authenticator\DavOnUrlTokenExtractor;
|
||||
use Lexik\Bundle\JWTAuthenticationBundle\Exception\InvalidTokenException;
|
||||
use Lexik\Bundle\JWTAuthenticationBundle\Exception\JWTDecodeFailureException;
|
||||
use Lexik\Bundle\JWTAuthenticationBundle\Exception\MissingTokenException;
|
||||
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
|
||||
|
||||
/**
|
||||
* JWT authenticator for DAV URL endpoints.
|
||||
*/
|
||||
class JWTOnDavUrlAuthenticator extends AbstractAuthenticator
|
||||
{
|
||||
public function __construct(
|
||||
private readonly JWTTokenManagerInterface $jwtManager,
|
||||
private readonly DavOnUrlTokenExtractor $davOnUrlTokenExtractor,
|
||||
) {
|
||||
}
|
||||
|
||||
public function supports(Request $request): ?bool
|
||||
{
|
||||
return false !== $this->davOnUrlTokenExtractor->extract($request);
|
||||
}
|
||||
|
||||
public function authenticate(Request $request): Passport
|
||||
{
|
||||
$token = $this->davOnUrlTokenExtractor->extract($request);
|
||||
|
||||
if (false === $token) {
|
||||
throw new MissingTokenException('JWT Token not found');
|
||||
}
|
||||
|
||||
try {
|
||||
$payload = $this->jwtManager->parse($token);
|
||||
} catch (JWTDecodeFailureException $e) {
|
||||
throw new InvalidTokenException('Invalid JWT Token', 0, $e);
|
||||
}
|
||||
|
||||
$username = $payload['username'] ?? $payload['email'] ?? $payload['user_id'] ?? null;
|
||||
|
||||
if (null === $username) {
|
||||
throw new InvalidTokenException('Invalid JWT Token: Username not found');
|
||||
}
|
||||
|
||||
return new SelfValidatingPassport(new UserBadge($username));
|
||||
}
|
||||
|
||||
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
|
||||
{
|
||||
// On success, let the request continue
|
||||
return null;
|
||||
}
|
||||
|
||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
|
||||
{
|
||||
throw $exception;
|
||||
}
|
||||
}
|
@@ -21,7 +21,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_event');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -21,7 +21,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_france_travail_api');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -21,7 +21,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_job');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\ArgumentResolver;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
|
||||
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
|
||||
|
||||
/**
|
||||
* Resolves entity arguments for controllers.
|
||||
*
|
||||
* This replaces the functionality previously provided by SensioFrameworkExtraBundle.
|
||||
*/
|
||||
class EntityValueResolver implements ValueResolverInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ManagerRegistry $doctrine,
|
||||
) {}
|
||||
|
||||
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||
{
|
||||
$type = $argument->getType();
|
||||
if (null === $type || !class_exists($type) || !$this->isEntity($type)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$name = $argument->getName();
|
||||
|
||||
// If the argument name is 'id', we don't want to resolve it as an entity
|
||||
if ('id' === $name) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Try to find the entity ID from various possible parameter names
|
||||
$id = $this->findEntityId($request, $name, $type);
|
||||
|
||||
if (null === $id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$entity = $this->doctrine->getRepository($type)->find($id);
|
||||
|
||||
if (null === $entity) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [$entity];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to find the entity ID from various possible parameter names.
|
||||
*
|
||||
* This method checks for the following parameter names in order:
|
||||
* 1. The parameter name specified in the route (e.g., 'id', 'person_id', 'household_id')
|
||||
* 2. A parameter named after the entity with 'Id' suffix (e.g., 'personId' for Person entity)
|
||||
* 3. A parameter named after the entity with '_id' suffix (e.g., 'person_id' for Person entity)
|
||||
* 4. The 'id' parameter as a fallback
|
||||
*/
|
||||
private function findEntityId(Request $request, string $name, string $type): mixed
|
||||
{
|
||||
// Common parameter naming patterns
|
||||
$possibleNames = [
|
||||
$name . 'Id',
|
||||
$name . '_id',
|
||||
$this->getShortClassName($type) . '_id',
|
||||
$this->getShortClassName($type) . 'Id',
|
||||
'id',
|
||||
];
|
||||
|
||||
// Special cases based on observed @ParamConverter usage
|
||||
$specialCases = [
|
||||
'Household' => ['household_id'],
|
||||
'AccompanyingCourse' => ['accompanying_period_id'],
|
||||
'AccompanyingPeriod' => ['accompanying_period_id'],
|
||||
'Event' => ['event_id'],
|
||||
'User' => ['userId'],
|
||||
'Person' => ['person_id'],
|
||||
'Action' => ['action_id'],
|
||||
];
|
||||
|
||||
// Add special cases if applicable
|
||||
$shortClassName = $this->getShortClassName($type);
|
||||
if (isset($specialCases[$shortClassName])) {
|
||||
$possibleNames = array_merge($specialCases[$shortClassName], $possibleNames);
|
||||
}
|
||||
|
||||
// Try each possible parameter name
|
||||
foreach ($possibleNames as $paramName) {
|
||||
if ($request->attributes->has($paramName)) {
|
||||
return $request->attributes->get($paramName);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the short class name (without namespace) from a fully qualified class name.
|
||||
*/
|
||||
private function getShortClassName(string $class): string
|
||||
{
|
||||
$parts = explode('\\', $class);
|
||||
return end($parts);
|
||||
}
|
||||
|
||||
private function isEntity(string $class): bool
|
||||
{
|
||||
if (!$this->doctrine->getManagerForClass($class) instanceof EntityManagerInterface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !$this->doctrine->getManagerForClass($class)->getMetadataFactory()->isTransient($class);
|
||||
}
|
||||
}
|
@@ -31,7 +31,7 @@ class Configuration implements ConfigurationInterface
|
||||
$this->setWidgetFactories($widgetFactories);
|
||||
}
|
||||
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_main');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -25,7 +25,7 @@ class Configuration implements ConfigurationInterface
|
||||
.' any birthdate is not allowed. The birthdate is expressed as ISO8601 : '
|
||||
.'https://en.wikipedia.org/wiki/ISO_8601#Durations';
|
||||
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('cl_chill_person');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -21,7 +21,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_report');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -21,7 +21,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_task');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -21,7 +21,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_third_party');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -16,7 +16,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
final class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Builder\TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_wopi');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ChampsLibres\WopiBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
final class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('wopi');
|
||||
|
||||
/** @var \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $rootNode */
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
||||
/** @phpstan-ignore-next-line */
|
||||
$rootNode
|
||||
->children()
|
||||
->scalarNode('server')->end()
|
||||
->enumNode('version_management')->values(['version', 'timestamp'])
|
||||
->info('Manager document versioning through version (Office 365) or last modified time (Collabora Online, CODE, etc.)')
|
||||
->defaultValue('timestamp')
|
||||
->end()
|
||||
->booleanNode('enable_lock')->defaultTrue()->end()
|
||||
->end();
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\DependencyInjection;
|
||||
|
||||
/**
|
||||
* ContainerAwareTrait implementation.
|
||||
*
|
||||
* This trait is a replacement for the original Symfony ContainerAwareTrait
|
||||
* which has been removed in newer Symfony versions.
|
||||
*/
|
||||
trait ContainerAwareTrait
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface|null
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Sets the container.
|
||||
*/
|
||||
public function setContainer(ContainerInterface $container = null): void
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user