mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-26 01:23:49 +00:00
Apply new CS rules on the webdav feature
This commit is contained in:
@@ -27,9 +27,10 @@ final readonly class DavOnUrlTokenExtractor implements TokenExtractorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function extract(Request $request): string|false
|
||||
public function extract(Request $request): false|string
|
||||
{
|
||||
$uri = $request->getRequestUri();
|
||||
|
||||
@@ -41,13 +42,13 @@ final readonly class DavOnUrlTokenExtractor implements TokenExtractorInterface
|
||||
);
|
||||
|
||||
if (2 > count($segments)) {
|
||||
$this->logger->info("not enough segment for parsing URL");
|
||||
$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");
|
||||
$this->logger->info('the first segment of the url must be DAV');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -43,11 +43,9 @@ class DavTokenAuthenticationEventSubscriber implements EventSubscriberInterface
|
||||
$token->setAttribute(self::ACTIONS, match ($payload['e']) {
|
||||
0 => StoredObjectRoleEnum::SEE,
|
||||
1 => StoredObjectRoleEnum::EDIT,
|
||||
default => throw new \UnexpectedValueException("unsupported value for e parameter")
|
||||
default => throw new \UnexpectedValueException('unsupported value for e parameter')
|
||||
});
|
||||
|
||||
$token->setAttribute(self::STORED_OBJECT, $payload['so']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -17,14 +17,15 @@ use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* Provide a JWT Token which will be valid for viewing or editing a document
|
||||
* Provide a JWT Token which will be valid for viewing or editing a document.
|
||||
*/
|
||||
final readonly class JWTDavTokenProvider implements JWTDavTokenProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private JWTTokenManagerInterface $JWTTokenManager,
|
||||
private Security $security,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function createToken(StoredObject $storedObject, StoredObjectRoleEnum $roleEnum): string
|
||||
{
|
||||
@@ -44,5 +45,4 @@ final readonly class JWTDavTokenProvider implements JWTDavTokenProviderInterface
|
||||
|
||||
return \DateTimeImmutable::createFromFormat('U', (string) $jwt['exp']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
|
||||
|
||||
/**
|
||||
* Provide a JWT Token which will be valid for viewing or editing a document
|
||||
* Provide a JWT Token which will be valid for viewing or editing a document.
|
||||
*/
|
||||
interface JWTDavTokenProviderInterface
|
||||
{
|
||||
|
Reference in New Issue
Block a user