mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Implement StoredObject permissions WOPI AuthorizationManager.php
This commit is contained in:
parent
3262a1dd02
commit
345f379650
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\WopiBundle\Service\Wopi;
|
namespace Chill\WopiBundle\Service\Wopi;
|
||||||
|
|
||||||
use ChampsLibres\WopiLib\Contract\Entity\Document;
|
use ChampsLibres\WopiLib\Contract\Entity\Document;
|
||||||
|
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
|
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
|
||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
@ -60,12 +61,17 @@ class AuthorizationManager implements \ChampsLibres\WopiBundle\Contracts\Authori
|
|||||||
|
|
||||||
public function userCanPresent(string $accessToken, Document $document, RequestInterface $request): bool
|
public function userCanPresent(string $accessToken, Document $document, RequestInterface $request): bool
|
||||||
{
|
{
|
||||||
|
if ($this->security->isGranted(StoredObjectRoleEnum::SEE->value, $document)) {
|
||||||
|
|
||||||
return $this->isTokenValid($accessToken, $document, $request);
|
return $this->isTokenValid($accessToken, $document, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function userCanRead(string $accessToken, Document $document, RequestInterface $request): bool
|
public function userCanRead(string $accessToken, Document $document, RequestInterface $request): bool
|
||||||
{
|
{
|
||||||
if ($this->security->isGranted('SEE', $document)) {
|
if ($this->security->isGranted(StoredObjectRoleEnum::SEE->value, $document)) {
|
||||||
return $this->isTokenValid($accessToken, $document, $request);
|
return $this->isTokenValid($accessToken, $document, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +85,7 @@ class AuthorizationManager implements \ChampsLibres\WopiBundle\Contracts\Authori
|
|||||||
|
|
||||||
public function userCanWrite(string $accessToken, Document $document, RequestInterface $request): bool
|
public function userCanWrite(string $accessToken, Document $document, RequestInterface $request): bool
|
||||||
{
|
{
|
||||||
if ($this->security->isGranted('EDIT', $document)) {
|
if ($this->security->isGranted(StoredObjectRoleEnum::EDIT->value, $document)) {
|
||||||
return $this->isTokenValid($accessToken, $document, $request);
|
return $this->isTokenValid($accessToken, $document, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user