From 7a31094952f0b5695d44c09cad2b9789ce2ad753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20U=C3=A7ar?= Date: Sat, 3 Aug 2024 13:03:28 +0200 Subject: [PATCH] move share structure implement new functions --- .../Node/Share/{ => Public}/PublicShare.php | 49 +++++++++++++++++- .../Share/{ => Public}/PublicShareSingle.php | 2 +- .../Api/Node/Share/{ => Regular}/Remove.php | 2 +- .../Api/Node/Share/{ => Regular}/Share.php | 2 +- .../Share/{ => Regular}/ShareableUsers.php | 2 +- .../Exception/Node/Share/ShareException.php | 28 ++++++++++ .../Api/Node/Share/PublicShareFactory.php | 4 +- .../Node/Share/PublicShareSingleFactory.php | 2 +- .../Factory/Api/Node/Share/RemoveFactory.php | 4 +- .../Factory/Api/Node/Share/ShareFactory.php | 2 +- .../Api/Node/ShareableUsersFactory.php | 4 +- .../Repository/PublicShareRepository.php | 51 +++++++++++++++++++ .../{ => Public}/PublicShareSingleTest.php | 4 +- .../Share/{ => Public}/PublicShareTest.php | 4 +- .../Node/Share/{ => Regular}/RemoveTest.php | 4 +- .../Node/Share/{ => Regular}/ShareTest.php | 4 +- .../Regular}/ShareableUsersTest.php | 6 +-- apps/PasswordManager/config/api_router.php | 16 ++++-- apps/PasswordManager/config/dependencies.php | 40 +++++++-------- 19 files changed, 182 insertions(+), 48 deletions(-) rename apps/PasswordManager/Api/Node/Share/{ => Public}/PublicShare.php (66%) rename apps/PasswordManager/Api/Node/Share/{ => Public}/PublicShareSingle.php (98%) rename apps/PasswordManager/Api/Node/Share/{ => Regular}/Remove.php (96%) rename apps/PasswordManager/Api/Node/Share/{ => Regular}/Share.php (98%) rename apps/PasswordManager/Api/Node/Share/{ => Regular}/ShareableUsers.php (98%) create mode 100644 apps/PasswordManager/Exception/Node/Share/ShareException.php rename apps/PasswordManager/Test/Integration/Api/Node/Share/{ => Public}/PublicShareSingleTest.php (97%) rename apps/PasswordManager/Test/Integration/Api/Node/Share/{ => Public}/PublicShareTest.php (98%) rename apps/PasswordManager/Test/Integration/Api/Node/Share/{ => Regular}/RemoveTest.php (96%) rename apps/PasswordManager/Test/Integration/Api/Node/Share/{ => Regular}/ShareTest.php (98%) rename apps/PasswordManager/Test/Integration/Api/Node/{ => Share/Regular}/ShareableUsersTest.php (93%) diff --git a/apps/PasswordManager/Api/Node/Share/PublicShare.php b/apps/PasswordManager/Api/Node/Share/Public/PublicShare.php similarity index 66% rename from apps/PasswordManager/Api/Node/Share/PublicShare.php rename to apps/PasswordManager/Api/Node/Share/Public/PublicShare.php index ac8291f8..da9ce807 100755 --- a/apps/PasswordManager/Api/Node/Share/PublicShare.php +++ b/apps/PasswordManager/Api/Node/Share/Public/PublicShare.php @@ -19,15 +19,20 @@ * along with this program. If not, see . */ -namespace KSA\PasswordManager\Api\Node\Share; +namespace KSA\PasswordManager\Api\Node\Share\Public; +use Doctrine\DBAL\Exception; +use Keestash\Exception\User\UserNotFoundException; use KSA\PasswordManager\Entity\IResponseCodes; use KSA\PasswordManager\Entity\Share\NullShare; use KSA\PasswordManager\Exception\PasswordManagerException; use KSA\PasswordManager\Repository\Node\NodeRepository; use KSA\PasswordManager\Repository\PublicShareRepository; +use KSA\PasswordManager\Service\AccessService; use KSA\PasswordManager\Service\Node\Share\ShareService; use KSP\Api\IResponse; +use KSP\Api\IVerb; +use KSP\Core\DTO\Token\IToken; use KSP\Core\Service\HTTP\IResponseService; use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; @@ -47,10 +52,52 @@ public function __construct( , private PublicShareRepository $shareRepository , private LoggerInterface $logger , private IResponseService $responseService + , private AccessService $accessService ) { } public function handle(ServerRequestInterface $request): ResponseInterface { + return match (strtolower($request->getMethod())) { + IVerb::POST => $this->handlePost($request), + IVerb::DELETE => $this->handleDelete($request), + default => new JsonResponse([], IResponse::BAD_REQUEST), + }; + } + + private function handleDelete(ServerRequestInterface $request): ResponseInterface { + try { + $parameters = (array) $request->getParsedBody(); + $shareId = $parameters["shareId"] ?? null; + /** @var IToken $token */ + $token = $request->getAttribute(IToken::class); + + if ($shareId === null) { + return new JsonResponse([], IResponse::BAD_REQUEST); + } + + $share = $this->shareRepository->getShareById($shareId); + + if ( + $share instanceof NullShare + || $this->shareService->isExpired($share) + ) { + return new JsonResponse([], IResponse::NOT_FOUND); + } + + $node = $this->nodeRepository->getNode($share->getNodeId(), 0, 0); + if (false === $this->accessService->hasAccess($node, $token->getUser())) { + return new JsonResponse([], IResponse::FORBIDDEN); + } + + $this->shareRepository->remove($share); + return new JsonResponse([], IResponse::OK); + } catch (Exception|PasswordManagerException|UserNotFoundException $e) { + $this->logger->error('error deleting public share', ['e' => $e]); + return new JsonResponse([], IResponse::NOT_IMPLEMENTED); + } + } + + private function handlePost(ServerRequestInterface $request): ResponseInterface { try { $parameters = (array) $request->getParsedBody(); diff --git a/apps/PasswordManager/Api/Node/Share/PublicShareSingle.php b/apps/PasswordManager/Api/Node/Share/Public/PublicShareSingle.php similarity index 98% rename from apps/PasswordManager/Api/Node/Share/PublicShareSingle.php rename to apps/PasswordManager/Api/Node/Share/Public/PublicShareSingle.php index 2765f9a9..8e753383 100755 --- a/apps/PasswordManager/Api/Node/Share/PublicShareSingle.php +++ b/apps/PasswordManager/Api/Node/Share/Public/PublicShareSingle.php @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -namespace KSA\PasswordManager\Api\Node\Share; +namespace KSA\PasswordManager\Api\Node\Share\Public; use DateTimeImmutable; use Exception; diff --git a/apps/PasswordManager/Api/Node/Share/Remove.php b/apps/PasswordManager/Api/Node/Share/Regular/Remove.php similarity index 96% rename from apps/PasswordManager/Api/Node/Share/Remove.php rename to apps/PasswordManager/Api/Node/Share/Regular/Remove.php index 774dedf8..418341ee 100755 --- a/apps/PasswordManager/Api/Node/Share/Remove.php +++ b/apps/PasswordManager/Api/Node/Share/Regular/Remove.php @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -namespace KSA\PasswordManager\Api\Node\Share; +namespace KSA\PasswordManager\Api\Node\Share\Regular; use Keestash\Api\Response\JsonResponse; use KSA\PasswordManager\Repository\Node\NodeRepository; diff --git a/apps/PasswordManager/Api/Node/Share/Share.php b/apps/PasswordManager/Api/Node/Share/Regular/Share.php similarity index 98% rename from apps/PasswordManager/Api/Node/Share/Share.php rename to apps/PasswordManager/Api/Node/Share/Regular/Share.php index 3c52dd6c..332eabeb 100755 --- a/apps/PasswordManager/Api/Node/Share/Share.php +++ b/apps/PasswordManager/Api/Node/Share/Regular/Share.php @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -namespace KSA\PasswordManager\Api\Node\Share; +namespace KSA\PasswordManager\Api\Node\Share\Regular; use Exception; use Keestash\Api\Response\JsonResponse; diff --git a/apps/PasswordManager/Api/Node/Share/ShareableUsers.php b/apps/PasswordManager/Api/Node/Share/Regular/ShareableUsers.php similarity index 98% rename from apps/PasswordManager/Api/Node/Share/ShareableUsers.php rename to apps/PasswordManager/Api/Node/Share/Regular/ShareableUsers.php index d9f51bf0..692151cd 100755 --- a/apps/PasswordManager/Api/Node/Share/ShareableUsers.php +++ b/apps/PasswordManager/Api/Node/Share/Regular/ShareableUsers.php @@ -12,7 +12,7 @@ * the Keestash software and contains warranty information and liability disclaimers. */ -namespace KSA\PasswordManager\Api\Node\Share; +namespace KSA\PasswordManager\Api\Node\Share\Regular; use doganoo\PHPAlgorithms\Datastructure\Lists\ArrayList\ArrayList; use Keestash\Core\DTO\Http\JWT\Audience; diff --git a/apps/PasswordManager/Exception/Node/Share/ShareException.php b/apps/PasswordManager/Exception/Node/Share/ShareException.php new file mode 100644 index 00000000..34b39473 --- /dev/null +++ b/apps/PasswordManager/Exception/Node/Share/ShareException.php @@ -0,0 +1,28 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace KSA\PasswordManager\Exception\Node\Share; + +use KSA\PasswordManager\Exception\PasswordManagerException; + +class ShareException extends PasswordManagerException { + +} diff --git a/apps/PasswordManager/Factory/Api/Node/Share/PublicShareFactory.php b/apps/PasswordManager/Factory/Api/Node/Share/PublicShareFactory.php index d46ea0a4..55210c3a 100644 --- a/apps/PasswordManager/Factory/Api/Node/Share/PublicShareFactory.php +++ b/apps/PasswordManager/Factory/Api/Node/Share/PublicShareFactory.php @@ -21,9 +21,10 @@ namespace KSA\PasswordManager\Factory\Api\Node\Share; -use KSA\PasswordManager\Api\Node\Share\PublicShare; +use KSA\PasswordManager\Api\Node\Share\Public\PublicShare; use KSA\PasswordManager\Repository\Node\NodeRepository; use KSA\PasswordManager\Repository\PublicShareRepository; +use KSA\PasswordManager\Service\AccessService; use KSA\PasswordManager\Service\Node\Share\ShareService; use KSP\Core\Service\HTTP\IResponseService; use Psr\Container\ContainerInterface; @@ -38,6 +39,7 @@ public function __invoke(ContainerInterface $container): PublicShare { , $container->get(PublicShareRepository::class) , $container->get(LoggerInterface::class) , $container->get(IResponseService::class) + , $container->get(AccessService::class) ); } diff --git a/apps/PasswordManager/Factory/Api/Node/Share/PublicShareSingleFactory.php b/apps/PasswordManager/Factory/Api/Node/Share/PublicShareSingleFactory.php index 98720d54..0de9621d 100644 --- a/apps/PasswordManager/Factory/Api/Node/Share/PublicShareSingleFactory.php +++ b/apps/PasswordManager/Factory/Api/Node/Share/PublicShareSingleFactory.php @@ -21,7 +21,7 @@ namespace KSA\PasswordManager\Factory\Api\Node\Share; -use KSA\PasswordManager\Api\Node\Share\PublicShareSingle; +use KSA\PasswordManager\Api\Node\Share\Public\PublicShareSingle; use KSA\PasswordManager\Repository\Node\NodeRepository; use KSA\PasswordManager\Repository\PublicShareRepository; use KSA\PasswordManager\Service\Node\Credential\CredentialService; diff --git a/apps/PasswordManager/Factory/Api/Node/Share/RemoveFactory.php b/apps/PasswordManager/Factory/Api/Node/Share/RemoveFactory.php index 391d8a92..d62d8c74 100644 --- a/apps/PasswordManager/Factory/Api/Node/Share/RemoveFactory.php +++ b/apps/PasswordManager/Factory/Api/Node/Share/RemoveFactory.php @@ -21,7 +21,7 @@ namespace KSA\PasswordManager\Factory\Api\Node\Share; -use KSA\PasswordManager\Api\Node\Share\Remove; +use KSA\PasswordManager\Api\Node\Share\Regular\Remove; use KSA\PasswordManager\Repository\Node\NodeRepository; use Psr\Container\ContainerInterface; @@ -33,4 +33,4 @@ public function __invoke(ContainerInterface $container): Remove { ); } -} \ No newline at end of file +} diff --git a/apps/PasswordManager/Factory/Api/Node/Share/ShareFactory.php b/apps/PasswordManager/Factory/Api/Node/Share/ShareFactory.php index 535c2db3..8a73065b 100644 --- a/apps/PasswordManager/Factory/Api/Node/Share/ShareFactory.php +++ b/apps/PasswordManager/Factory/Api/Node/Share/ShareFactory.php @@ -21,7 +21,7 @@ namespace KSA\PasswordManager\Factory\Api\Node\Share; -use KSA\PasswordManager\Api\Node\Share\Share; +use KSA\PasswordManager\Api\Node\Share\Regular\Share; use KSA\PasswordManager\Repository\Node\NodeRepository; use KSA\PasswordManager\Service\Node\NodeService; use KSA\PasswordManager\Service\Node\Share\ShareService; diff --git a/apps/PasswordManager/Factory/Api/Node/ShareableUsersFactory.php b/apps/PasswordManager/Factory/Api/Node/ShareableUsersFactory.php index ee11c6ab..3a76c69c 100644 --- a/apps/PasswordManager/Factory/Api/Node/ShareableUsersFactory.php +++ b/apps/PasswordManager/Factory/Api/Node/ShareableUsersFactory.php @@ -21,7 +21,7 @@ namespace KSA\PasswordManager\Factory\Api\Node; -use KSA\PasswordManager\Api\Node\Share\ShareableUsers; +use KSA\PasswordManager\Api\Node\Share\Regular\ShareableUsers; use KSA\PasswordManager\Repository\Node\NodeRepository; use KSP\Core\Repository\User\IUserRepository; use KSP\Core\Service\HTTP\IJWTService; @@ -39,4 +39,4 @@ public function __invoke(ContainerInterface $container): ShareableUsers { ); } -} \ No newline at end of file +} diff --git a/apps/PasswordManager/Repository/PublicShareRepository.php b/apps/PasswordManager/Repository/PublicShareRepository.php index e157b833..4104a88b 100755 --- a/apps/PasswordManager/Repository/PublicShareRepository.php +++ b/apps/PasswordManager/Repository/PublicShareRepository.php @@ -27,6 +27,7 @@ use KSA\PasswordManager\Entity\Node\Node; use KSA\PasswordManager\Entity\Share\NullShare; use KSA\PasswordManager\Entity\Share\PublicShare; +use KSA\PasswordManager\Exception\Node\Share\ShareException; use KSA\PasswordManager\Exception\PasswordManagerException; use KSP\Core\Backend\IBackend; use KSP\Core\DTO\User\IUser; @@ -115,6 +116,42 @@ public function getShare(string $hash): PublicShare { } + public function getShareById(int $id): PublicShare { + $queryBuilder = $this->backend->getConnection()->createQueryBuilder(); + $queryBuilder->select( + [ + 's.id' + , 's.hash' + , 's.expire_ts' + , 's.node_id' + ] + ) + ->from('pwm_public_share', 's') + ->where('s.`id` = ?') + ->setParameter(0, $id); + + $result = $queryBuilder->executeQuery(); + $rows = $result->fetchAllNumeric(); + + if (0 === count($rows)) { + return new NullShare(); + } + + $row = $rows[0]; + $shareId = $row[0]; + $shareHash = $row[1]; + $expireTs = $row[2]; + $nodeId = $row[3]; + + return new PublicShare( + (int) $shareId, + (int) $nodeId, + (string) $shareHash, + $this->dateTimeService->fromFormat($expireTs) + ); + + } + public function getShareByNode(Node $node): PublicShare { $queryBuilder = $this->backend->getConnection()->createQueryBuilder(); $queryBuilder->select( @@ -209,6 +246,20 @@ public function removeByUser(IUser $user): bool { } } + public function remove(PublicShare $share): PublicShare { + try { + $queryBuilder = $this->backend->getConnection()->createQueryBuilder(); + $queryBuilder->delete('pwm_public_share', 'pps') + ->where('id = ?') + ->setParameter(0, $share->getId()) + ->executeStatement(); + return $share; + } catch (Exception $e) { + $this->logger->warning('can not remove users public share', ['share' => $share, 'exception' => $e]); + throw new ShareException(); + } + } + public function removeOutdated(): bool { $now = $this->dateTimeService->toYMDHIS(new DateTimeImmutable()); try { diff --git a/apps/PasswordManager/Test/Integration/Api/Node/Share/PublicShareSingleTest.php b/apps/PasswordManager/Test/Integration/Api/Node/Share/Public/PublicShareSingleTest.php similarity index 97% rename from apps/PasswordManager/Test/Integration/Api/Node/Share/PublicShareSingleTest.php rename to apps/PasswordManager/Test/Integration/Api/Node/Share/Public/PublicShareSingleTest.php index 8d420ef6..faba269a 100644 --- a/apps/PasswordManager/Test/Integration/Api/Node/Share/PublicShareSingleTest.php +++ b/apps/PasswordManager/Test/Integration/Api/Node/Share/Public/PublicShareSingleTest.php @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -namespace Integration\Api\Node\Share; +namespace Integration\Api\Node\Share\Public; -use KSA\PasswordManager\Api\Node\Share\PublicShareSingle; +use KSA\PasswordManager\Api\Node\Share\Public\PublicShareSingle; use KSA\PasswordManager\Entity\Share\PublicShare; use KSA\PasswordManager\Repository\PublicShareRepository; use KSA\PasswordManager\Service\Node\Credential\CredentialService; diff --git a/apps/PasswordManager/Test/Integration/Api/Node/Share/PublicShareTest.php b/apps/PasswordManager/Test/Integration/Api/Node/Share/Public/PublicShareTest.php similarity index 98% rename from apps/PasswordManager/Test/Integration/Api/Node/Share/PublicShareTest.php rename to apps/PasswordManager/Test/Integration/Api/Node/Share/Public/PublicShareTest.php index 8f7ab012..730d915b 100644 --- a/apps/PasswordManager/Test/Integration/Api/Node/Share/PublicShareTest.php +++ b/apps/PasswordManager/Test/Integration/Api/Node/Share/Public/PublicShareTest.php @@ -19,10 +19,10 @@ * along with this program. If not, see . */ -namespace Integration\Api\Node\Share; +namespace Integration\Api\Node\Share\Public; use DateTime; -use KSA\PasswordManager\Api\Node\Share\PublicShare; +use KSA\PasswordManager\Api\Node\Share\Public\PublicShare; use KSA\PasswordManager\ConfigProvider; use KSA\PasswordManager\Entity\IResponseCodes; use KSA\PasswordManager\Service\Node\Credential\CredentialService; diff --git a/apps/PasswordManager/Test/Integration/Api/Node/Share/RemoveTest.php b/apps/PasswordManager/Test/Integration/Api/Node/Share/Regular/RemoveTest.php similarity index 96% rename from apps/PasswordManager/Test/Integration/Api/Node/Share/RemoveTest.php rename to apps/PasswordManager/Test/Integration/Api/Node/Share/Regular/RemoveTest.php index 4c81d52a..d66eef66 100644 --- a/apps/PasswordManager/Test/Integration/Api/Node/Share/RemoveTest.php +++ b/apps/PasswordManager/Test/Integration/Api/Node/Share/Regular/RemoveTest.php @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -namespace Integration\Api\Node\Share; +namespace Integration\Api\Node\Share\Regular; -use KSA\PasswordManager\Api\Node\Share\Remove; +use KSA\PasswordManager\Api\Node\Share\Regular\Remove; use KSA\PasswordManager\Repository\PublicShareRepository; use KSA\PasswordManager\Service\Node\Share\ShareService; use KSA\PasswordManager\Test\Integration\TestCase; diff --git a/apps/PasswordManager/Test/Integration/Api/Node/Share/ShareTest.php b/apps/PasswordManager/Test/Integration/Api/Node/Share/Regular/ShareTest.php similarity index 98% rename from apps/PasswordManager/Test/Integration/Api/Node/Share/ShareTest.php rename to apps/PasswordManager/Test/Integration/Api/Node/Share/Regular/ShareTest.php index d5ee0d36..4450bf17 100644 --- a/apps/PasswordManager/Test/Integration/Api/Node/Share/ShareTest.php +++ b/apps/PasswordManager/Test/Integration/Api/Node/Share/Regular/ShareTest.php @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -namespace Integration\Api\Node\Share; +namespace Integration\Api\Node\Share\Regular; -use KSA\PasswordManager\Api\Node\Share\Share; +use KSA\PasswordManager\Api\Node\Share\Regular\Share; use KSA\PasswordManager\Test\Integration\TestCase; use Ramsey\Uuid\Uuid; diff --git a/apps/PasswordManager/Test/Integration/Api/Node/ShareableUsersTest.php b/apps/PasswordManager/Test/Integration/Api/Node/Share/Regular/ShareableUsersTest.php similarity index 93% rename from apps/PasswordManager/Test/Integration/Api/Node/ShareableUsersTest.php rename to apps/PasswordManager/Test/Integration/Api/Node/Share/Regular/ShareableUsersTest.php index 67dcc50a..52c6c3ea 100644 --- a/apps/PasswordManager/Test/Integration/Api/Node/ShareableUsersTest.php +++ b/apps/PasswordManager/Test/Integration/Api/Node/Share/Regular/ShareableUsersTest.php @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -namespace KSA\PasswordManager\Test\Integration\Api\Node; +namespace Integration\Api\Node\Share\Regular; -use KSA\PasswordManager\Api\Node\Share\ShareableUsers; +use KSA\PasswordManager\Api\Node\Share\Regular\ShareableUsers; use KSA\PasswordManager\Entity\Node\Credential\Credential; use KSA\PasswordManager\Repository\Node\NodeRepository; use KSA\PasswordManager\Test\Integration\TestCase; @@ -44,4 +44,4 @@ public function testShareableUsers(): void { $this->assertTrue(true === $this->getResponseService()->isValidResponse($response)); } -} \ No newline at end of file +} diff --git a/apps/PasswordManager/config/api_router.php b/apps/PasswordManager/config/api_router.php index 0ee40200..ae104382 100644 --- a/apps/PasswordManager/config/api_router.php +++ b/apps/PasswordManager/config/api_router.php @@ -41,11 +41,11 @@ use KSA\PasswordManager\Api\Node\Pwned\ChartData; use KSA\PasswordManager\Api\Node\Pwned\IsActive; use KSA\PasswordManager\Api\Node\Search; -use KSA\PasswordManager\Api\Node\Share\PublicShare; -use KSA\PasswordManager\Api\Node\Share\PublicShareSingle; -use KSA\PasswordManager\Api\Node\Share\Remove as RemoveShare; -use KSA\PasswordManager\Api\Node\Share\Share; -use KSA\PasswordManager\Api\Node\Share\ShareableUsers; +use KSA\PasswordManager\Api\Node\Share\Public\PublicShare; +use KSA\PasswordManager\Api\Node\Share\Public\PublicShareSingle; +use KSA\PasswordManager\Api\Node\Share\Regular\Remove as RemoveShare; +use KSA\PasswordManager\Api\Node\Share\Regular\Share; +use KSA\PasswordManager\Api\Node\Share\Regular\ShareableUsers; use KSA\PasswordManager\ConfigProvider; use KSA\PasswordManager\Middleware\NodeAccessMiddleware; use KSP\Api\IRoute; @@ -95,6 +95,12 @@ , IRoute::METHOD => IVerb::POST , IRoute::NAME => PublicShare::class ], + [ + IRoute::PATH => ConfigProvider::PASSWORD_MANAGER_PUBLIC_SHARE_PUBLIC + , IRoute::MIDDLEWARE => [NodeAccessMiddleware::class, PublicShare::class] + , IRoute::METHOD => IVerb::DELETE + , IRoute::NAME => PublicShare::class . '@' . IVerb::DELETE + ], [ IRoute::PATH => ConfigProvider::PASSWORD_MANAGER_PUBLIC_SHARE_REMOVE , IRoute::MIDDLEWARE => [NodeAccessMiddleware::class, RemoveShare::class] diff --git a/apps/PasswordManager/config/dependencies.php b/apps/PasswordManager/config/dependencies.php index 71d806fe..d64aade8 100644 --- a/apps/PasswordManager/config/dependencies.php +++ b/apps/PasswordManager/config/dependencies.php @@ -44,10 +44,10 @@ use KSA\PasswordManager\Api\Node\Pwned\ChartData; use KSA\PasswordManager\Api\Node\Pwned\IsActive; use KSA\PasswordManager\Api\Node\Search; -use KSA\PasswordManager\Api\Node\Share\PublicShare; -use KSA\PasswordManager\Api\Node\Share\PublicShareSingle; -use KSA\PasswordManager\Api\Node\Share\Share; -use KSA\PasswordManager\Api\Node\Share\ShareableUsers; +use KSA\PasswordManager\Api\Node\Share\Public\PublicShare; +use KSA\PasswordManager\Api\Node\Share\Public\PublicShareSingle; +use KSA\PasswordManager\Api\Node\Share\Regular\Share; +use KSA\PasswordManager\Api\Node\Share\Regular\ShareableUsers; use KSA\PasswordManager\Command\Node\Credential\CreateCredential; use KSA\PasswordManager\Command\Node\Dump; use KSA\PasswordManager\Command\Node\DumpAll; @@ -140,28 +140,28 @@ ConfigProvider::FACTORIES => [ // api // ---- comment - AddComment::class => AddCommentFactory::class - , Get::class => GetFactory::class - , Remove::class => RemoveFactory::class + AddComment::class => AddCommentFactory::class + , Get::class => GetFactory::class + , Remove::class => RemoveFactory::class // ---- generate - , Generate::class => GenerateFactory::class - , Quality::class => QualityFactory::class + , Generate::class => GenerateFactory::class + , Quality::class => QualityFactory::class // ---- PublicShare - , PublicShare::class => PublicShareFactory::class - , PublicShareSingle::class => PublicShareSingleFactory::class - , \KSA\PasswordManager\Api\Node\Share\Remove::class => \KSA\PasswordManager\Factory\Api\Node\Share\RemoveFactory::class - , Share::class => ShareFactory::class + , PublicShare::class => PublicShareFactory::class + , PublicShareSingle::class => PublicShareSingleFactory::class + , \KSA\PasswordManager\Api\Node\Share\Regular\Remove::class => \KSA\PasswordManager\Factory\Api\Node\Share\RemoveFactory::class + , Share::class => ShareFactory::class // ---- Node - , \KSA\PasswordManager\Api\Node\Get\Get::class => \KSA\PasswordManager\Factory\Api\Node\Get\GetFactory::class - , Alpha::class => AlphaFactory::class - , Beta::class => BetaFactory::class - , GetByName::class => GetByNameFactory::class - , Move::class => MoveFactory::class - , ShareableUsers::class => ShareableUsersFactory::class - , Delete::class => DeleteFactory::class + , \KSA\PasswordManager\Api\Node\Get\Get::class => \KSA\PasswordManager\Factory\Api\Node\Get\GetFactory::class + , Alpha::class => AlphaFactory::class + , Beta::class => BetaFactory::class + , GetByName::class => GetByNameFactory::class + , Move::class => MoveFactory::class + , ShareableUsers::class => ShareableUsersFactory::class + , Delete::class => DeleteFactory::class , \KSA\PasswordManager\Api\Node\Folder\Update::class => \KSA\PasswordManager\Factory\Api\Node\UpdateFactory::class , ListAll::class => ListAllFactory::class