From 9883e5f9db5151e20671fb6697dd3ab47f7c195b Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 11 Oct 2024 17:11:23 +0400 Subject: [PATCH 01/22] =?UTF-8?q?TD-322:=20[BACK].=20[=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B8=D1=81=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9=D0=BD=D0=B5=D1=80=D0=B5=20?= =?UTF-8?q?signer]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/signer.iml | 2 - backend/.env | 19 +-- backend/composer.json | 1 + backend/composer.lock | 103 +++++++++++++++- backend/config/services.yaml | 15 ++- backend/src/Controller/SignController.php | 18 --- backend/src/Entity/.gitignore | 0 .../External/Api/AbstractApi.php | 23 ++++ .../Infrastructure/External/Api/ApiSleep.php | 13 +++ .../External/Api/BinaryStringFileResult.php | 26 +++++ .../External/Api/ResponseHandler.php | 110 ++++++++++++++++++ .../Http/RequestDtoInterface.php | 7 ++ .../Http/RequestDtoResolver.php | 63 ++++++++++ backend/src/Repository/.gitignore | 0 backend/src/Sign/Api/Api.php | 57 +++++++++ backend/src/Sign/Api/ApiParams.php | 13 +++ backend/src/Sign/Api/Request/SignRequest.php | 14 +++ backend/src/{ => Sign}/Controller/.gitignore | 0 .../src/Sign/Controller/SignController.php | 36 ++++++ backend/src/Sign/SignService.php | 64 ++++++++++ 20 files changed, 542 insertions(+), 42 deletions(-) delete mode 100644 backend/src/Controller/SignController.php delete mode 100644 backend/src/Entity/.gitignore create mode 100644 backend/src/Infrastructure/External/Api/AbstractApi.php create mode 100644 backend/src/Infrastructure/External/Api/ApiSleep.php create mode 100644 backend/src/Infrastructure/External/Api/BinaryStringFileResult.php create mode 100644 backend/src/Infrastructure/External/Api/ResponseHandler.php create mode 100644 backend/src/Infrastructure/Http/RequestDtoInterface.php create mode 100644 backend/src/Infrastructure/Http/RequestDtoResolver.php delete mode 100644 backend/src/Repository/.gitignore create mode 100644 backend/src/Sign/Api/Api.php create mode 100644 backend/src/Sign/Api/ApiParams.php create mode 100644 backend/src/Sign/Api/Request/SignRequest.php rename backend/src/{ => Sign}/Controller/.gitignore (100%) create mode 100644 backend/src/Sign/Controller/SignController.php create mode 100644 backend/src/Sign/SignService.php diff --git a/.idea/signer.iml b/.idea/signer.iml index dd914ac..21140ef 100644 --- a/.idea/signer.iml +++ b/.idea/signer.iml @@ -4,8 +4,6 @@ - - diff --git a/backend/.env b/backend/.env index 62f06bc..cdccb51 100644 --- a/backend/.env +++ b/backend/.env @@ -1,23 +1,5 @@ -# In all environments, the following files are loaded if they exist, -# the latter taking precedence over the former: -# -# * .env contains default values for the environment variables needed by the app -# * .env.local uncommitted file with local overrides -# * .env.$APP_ENV committed environment-specific defaults -# * .env.$APP_ENV.local uncommitted environment-specific overrides -# -# Real environment variables win over .env files. -# -# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. -# https://symfony.com/doc/current/configuration/secrets.html -# -# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). -# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration - -###> symfony/framework-bundle ### APP_ENV=dev APP_SECRET=850da55654c68f779822ea80d2b66a94 -###< symfony/framework-bundle ### ###> doctrine/doctrine-bundle ### # Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url @@ -28,3 +10,4 @@ APP_SECRET=850da55654c68f779822ea80d2b66a94 # DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8" ###< doctrine/doctrine-bundle ### +DOT_DOT_URL='http://dot-dot.local' \ No newline at end of file diff --git a/backend/composer.json b/backend/composer.json index 5068288..b04d8e4 100755 --- a/backend/composer.json +++ b/backend/composer.json @@ -17,6 +17,7 @@ "symfony/flex": "^2", "symfony/framework-bundle": "6.2.*", "symfony/runtime": "6.2.*", + "symfony/serializer": "6.2.*", "symfony/ux-chartjs": "*", "symfony/yaml": "6.2.*" }, diff --git a/backend/composer.lock b/backend/composer.lock index 4aa2c94..83bd001 100644 --- a/backend/composer.lock +++ b/backend/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bf87fa37fe523eb581063fa93c0fda64", + "content-hash": "0d9c45fd694083582028c80344c66518", "packages": [ { "name": "composer/package-versions-deprecated", @@ -5393,6 +5393,107 @@ ], "time": "2023-07-13T14:28:09+00:00" }, + { + "name": "symfony/serializer", + "version": "v6.2.13", + "source": { + "type": "git", + "url": "https://github.com/symfony/serializer.git", + "reference": "19083104e606ecf8a48baa8ed310c7a073887037" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/serializer/zipball/19083104e606ecf8a48baa8ed310c7a073887037", + "reference": "19083104e606ecf8a48baa8ed310c7a073887037", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "doctrine/annotations": "<1.12", + "phpdocumentor/reflection-docblock": "<3.2.2", + "phpdocumentor/type-resolver": "<1.4.0", + "symfony/dependency-injection": "<5.4", + "symfony/property-access": "<5.4", + "symfony/property-info": "<5.4.24|>=6,<6.2.11", + "symfony/uid": "<5.4", + "symfony/yaml": "<5.4" + }, + "require-dev": { + "doctrine/annotations": "^1.12|^2", + "phpdocumentor/reflection-docblock": "^3.2|^4.0|^5.0", + "symfony/cache": "^5.4|^6.0", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/error-handler": "^5.4|^6.0", + "symfony/filesystem": "^5.4|^6.0", + "symfony/form": "^5.4|^6.0", + "symfony/http-foundation": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/mime": "^5.4|^6.0", + "symfony/property-access": "^5.4|^6.0", + "symfony/property-info": "^5.4.24|^6.2.11", + "symfony/uid": "^5.4|^6.0", + "symfony/validator": "^5.4|^6.0", + "symfony/var-dumper": "^5.4|^6.0", + "symfony/var-exporter": "^5.4|^6.0", + "symfony/yaml": "^5.4|^6.0" + }, + "suggest": { + "psr/cache-implementation": "For using the metadata cache.", + "symfony/config": "For using the XML mapping loader.", + "symfony/mime": "For using a MIME type guesser within the DataUriNormalizer.", + "symfony/property-access": "For using the ObjectNormalizer.", + "symfony/property-info": "To deserialize relations.", + "symfony/var-exporter": "For using the metadata compiler.", + "symfony/yaml": "For using the default YAML mapping loader." + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Serializer\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/serializer/tree/v6.2.13" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-07-27T16:18:16+00:00" + }, { "name": "symfony/service-contracts", "version": "v3.5.0", diff --git a/backend/config/services.yaml b/backend/config/services.yaml index 2d6a76f..aede265 100644 --- a/backend/config/services.yaml +++ b/backend/config/services.yaml @@ -14,11 +14,20 @@ services: # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name App\: - resource: '../src/' + resource: '../src/*' exclude: - - '../src/DependencyInjection/' - - '../src/Entity/' - '../src/Kernel.php' + - '../src/*/Api/{Request,Response}' + - '../src/*/{Exception,Entity,Dto,Enum,Helper,Model}' # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones + + guzzle.http_client: + class: GuzzleHttp\Client + + GuzzleHttp\Client: '@guzzle.http_client' + + App\Api\ApiParams: + arguments: + $endPointUrl: '%env(DOT_DOT_URL)%' \ No newline at end of file diff --git a/backend/src/Controller/SignController.php b/backend/src/Controller/SignController.php deleted file mode 100644 index 129a91d..0000000 --- a/backend/src/Controller/SignController.php +++ /dev/null @@ -1,18 +0,0 @@ -client = $client; + $this->responseHandler = $responseHandler; + } +} diff --git a/backend/src/Infrastructure/External/Api/ApiSleep.php b/backend/src/Infrastructure/External/Api/ApiSleep.php new file mode 100644 index 0000000..cccea40 --- /dev/null +++ b/backend/src/Infrastructure/External/Api/ApiSleep.php @@ -0,0 +1,13 @@ + 0) { + sleep($time); + } + } +} diff --git a/backend/src/Infrastructure/External/Api/BinaryStringFileResult.php b/backend/src/Infrastructure/External/Api/BinaryStringFileResult.php new file mode 100644 index 0000000..6331c2c --- /dev/null +++ b/backend/src/Infrastructure/External/Api/BinaryStringFileResult.php @@ -0,0 +1,26 @@ +saveToTempFile($content); + } + + private function saveToTempFile(string $content): void + { + $this->tempFileName = sprintf('%s/%s_%s', sys_get_temp_dir(), 'Document', time()); + file_put_contents($this->tempFileName, $content); + } +} diff --git a/backend/src/Infrastructure/External/Api/ResponseHandler.php b/backend/src/Infrastructure/External/Api/ResponseHandler.php new file mode 100644 index 0000000..3e60520 --- /dev/null +++ b/backend/src/Infrastructure/External/Api/ResponseHandler.php @@ -0,0 +1,110 @@ +response->getBody()->getSize()); + } + + /** + * Возвращает ответ в текстовом виде, применит фильтры при их наличие. + * + * @return string + */ + public function getContent(): string + { + $content = (string)$this->response->getBody(); + + return $this->filterContent($content); + } + + /** + * Добавляет фильтр контента иногда необходимо поправить ответ, что бы в итоге возвращался нужный тип данных. + * Бывает иногда сервер, возвращает массив данных и при преобразовании json_decode возвращается + * массив вместо stdClass. + */ + public function addContentFilter(callable $filter): self + { + $this->contentFilters[] = $filter; + + return $this; + } + + /** + * Преобразует json в объект + * + * @return stdClass + */ + public function getContentStdFromJson(): stdClass + { + return json_decode($this->getContent()); + } + + public function getContentAsBinaryStingResult(): BinaryStringFileResult + { + return new BinaryStringFileResult($this->getContent()); + } + + /** + * @return stdClass[] + */ + public function getContentArrayStdFromJson(): array + { + return json_decode($this->getContent()); + } + + /** + * Преобразует json в массив. + */ + public function getContentJsonToArray(): array + { + return $this->contentIsEmpty() ? [] : json_decode($this->getContent(), true); + } + + /** + * Устанавливает ответ в обработчик. + */ + public function setResponse(ResponseInterface $response): self + { + $this->response = $response; + + return $this; + } + + /** + * Фильтруем ответ + * + * @param string $content + * + * @return string + */ + private function filterContent(string $content): string + { + if (!$this->contentFilters) { + return $content; + } + + foreach ($this->contentFilters as $filter) { + $content = $filter($content); + } + + $this->contentFilters = []; + + return $content; + } +} diff --git a/backend/src/Infrastructure/Http/RequestDtoInterface.php b/backend/src/Infrastructure/Http/RequestDtoInterface.php new file mode 100644 index 0000000..f809ecb --- /dev/null +++ b/backend/src/Infrastructure/Http/RequestDtoInterface.php @@ -0,0 +1,7 @@ +getType(); + + if (empty($type) || !class_exists($type)) { + return false; + } + + try { + $reflection = new ReflectionClass($type); + } catch (Exception $e) { + return false; + } + + return $reflection->implementsInterface(RequestDtoInterface::class); + } + + public function resolve(Request $request, ArgumentMetadata $argument): iterable + { + if (($class = $argument->getType()) === null || !class_exists($class)) { + throw new RuntimeException('dto exception'); + } + + $object = $this->serializer->deserialize($request->getContent(), $class, 'json'); + + if (is_object($object)) { + $this->validateObject($object); + } + + yield $object; + } + + private function validateObject(object $object): void + { + $errors = $this->validator->validate($object); + + if (count($errors) > 0) { + /* todo получать из вне сообщение для ошибки */ + throw new RuntimeException($errors, 'Ошибка валидации'); + } + } +} diff --git a/backend/src/Repository/.gitignore b/backend/src/Repository/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/backend/src/Sign/Api/Api.php b/backend/src/Sign/Api/Api.php new file mode 100644 index 0000000..55d2aeb --- /dev/null +++ b/backend/src/Sign/Api/Api.php @@ -0,0 +1,57 @@ + 'application/json', + 'Authorization' => $token, + ]; + $options = [ + 'multipart' => [ + [ + 'name' => 'type', + 'contents' => self::TYPE_OTHER + ], + [ + 'name' => 'file', + 'contents' => fopen($urlDocument, 'r'), + 'filename' => 'sign_attorney.pdf', + 'headers' => [ + 'Content-Type' => '' + ] + ] + ]]; + $request = new Request('POST', sprintf('%s%s%s', $url, self::API_DOCUMENT, $batch), $headers); + $res = $this->client->sendAsync($request, $options)->wait(); + + return $this->responseHandler->setResponse($res)->getContentJsonToArray(); + } + + public function download(string $url, string $token): BinaryStringFileResult + { + $params = [ + RequestOptions::HEADERS => [ + 'Authorization' => $token, + ], + ]; + + $response = $this->client->get($url, $params); + + return $this->responseHandler->setResponse($response)->getContentAsBinaryStingResult(); + } +} \ No newline at end of file diff --git a/backend/src/Sign/Api/ApiParams.php b/backend/src/Sign/Api/ApiParams.php new file mode 100644 index 0000000..cafcdc5 --- /dev/null +++ b/backend/src/Sign/Api/ApiParams.php @@ -0,0 +1,13 @@ +apiKey !== self::API_KEY) { + throw new AccessDeniedException('доступ запрещен'); + } + + $token = $request->server->get('HTTP_AUTHORIZATION'); + + return new JsonResponse($this->signService->signDocument($signRequest->url, $token, $signRequest->batch)); + } +} \ No newline at end of file diff --git a/backend/src/Sign/SignService.php b/backend/src/Sign/SignService.php new file mode 100644 index 0000000..a0a352f --- /dev/null +++ b/backend/src/Sign/SignService.php @@ -0,0 +1,64 @@ +api->apiParams = $this->apiParams; + + try { + $document = $this->api->download($url, $token); + + $this->sign($document->tempFileName); + + $response = $this->api->send($this->apiParams->endPointUrl, $token, $document->tempFileName . '_sign.pdf', $batch); + + $this->removeExistingDocument($document); + + return $response; + } catch (Exception $e) { + throw new RuntimeException($e->getMessage()); + } + } + + private function sign (string $documentUrl): void + { + match ($_ENV['APP_ENV']) { + 'dev' => $this->signDev($documentUrl), + 'prod' => $this->signProd($documentUrl), + }; + } + + private function signDev(string $documentUrl): void + { + exec(sprintf('cp %s %s_sign.pdf', $documentUrl, $documentUrl)); + } + + private function signProd(string $documentUrl): void + { + exec(sprintf('cp %s %s.pdf', $documentUrl, $documentUrl)); + exec(sprintf('pdfcpro sign /mnt/t/%s.pdf -out /mnt/t/%s_sign.pdf -cert ${SHA} -text "\n\t\tПодписано ЭП\n\t\t{subject/cn}\n\t\tСертификат {sha1}\n\t\tДействителен от {since} до {until}\n\t\tДата {date}\n\t\t{subject/t}\n\t\t{subject/fullname}\n\t\t" -fontfile /usr/local/share/fonts/Inter-Bold.ttf -fontsize 8 -x 2 -y 2 -w 96 -h 9', $documentUrl, $documentUrl)); + } + + private function removeExistingDocument(BinaryStringFileResult $document): void + { + if (file_exists($document->tempFileName)) { + unlink($document->tempFileName); + } + } +} \ No newline at end of file -- 2.40.1 From d4c3146c027af95db003283ba6dc016e124aa7ad Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 11 Oct 2024 17:17:29 +0400 Subject: [PATCH 02/22] =?UTF-8?q?TD-322:=20[BACK].=20[=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B8=D1=81=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9=D0=BD=D0=B5=D1=80=D0=B5=20?= =?UTF-8?q?signer]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/{Sign => }/Api/Api.php | 2 +- backend/src/{Sign => }/Api/ApiParams.php | 2 +- backend/src/{Sign => }/Api/Request/SignRequest.php | 2 +- backend/src/{Sign => }/Controller/.gitignore | 0 backend/src/{Sign => }/Controller/SignController.php | 8 ++++---- backend/src/Entity/.gitignore | 0 backend/src/Repository/.gitignore | 0 backend/src/{Sign => }/SignService.php | 6 +++--- 8 files changed, 10 insertions(+), 10 deletions(-) rename backend/src/{Sign => }/Api/Api.php (98%) rename backend/src/{Sign => }/Api/ApiParams.php (85%) rename backend/src/{Sign => }/Api/Request/SignRequest.php (86%) rename backend/src/{Sign => }/Controller/.gitignore (100%) rename backend/src/{Sign => }/Controller/SignController.php (91%) create mode 100644 backend/src/Entity/.gitignore create mode 100644 backend/src/Repository/.gitignore rename backend/src/{Sign => }/SignService.php (96%) diff --git a/backend/src/Sign/Api/Api.php b/backend/src/Api/Api.php similarity index 98% rename from backend/src/Sign/Api/Api.php rename to backend/src/Api/Api.php index 55d2aeb..5ceef4d 100644 --- a/backend/src/Sign/Api/Api.php +++ b/backend/src/Api/Api.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Sign\Api; +namespace App\Api; use App\Infrastructure\External\Api\AbstractApi; use App\Infrastructure\External\Api\BinaryStringFileResult; diff --git a/backend/src/Sign/Api/ApiParams.php b/backend/src/Api/ApiParams.php similarity index 85% rename from backend/src/Sign/Api/ApiParams.php rename to backend/src/Api/ApiParams.php index cafcdc5..f920f32 100644 --- a/backend/src/Sign/Api/ApiParams.php +++ b/backend/src/Api/ApiParams.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Sign\Api; +namespace App\Api; class ApiParams { diff --git a/backend/src/Sign/Api/Request/SignRequest.php b/backend/src/Api/Request/SignRequest.php similarity index 86% rename from backend/src/Sign/Api/Request/SignRequest.php rename to backend/src/Api/Request/SignRequest.php index 5453ad1..d0c20af 100644 --- a/backend/src/Sign/Api/Request/SignRequest.php +++ b/backend/src/Api/Request/SignRequest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Sign\Api\Request; +namespace App\Api\Request; use App\Infrastructure\Http\RequestDtoInterface; diff --git a/backend/src/Sign/Controller/.gitignore b/backend/src/Controller/.gitignore similarity index 100% rename from backend/src/Sign/Controller/.gitignore rename to backend/src/Controller/.gitignore diff --git a/backend/src/Sign/Controller/SignController.php b/backend/src/Controller/SignController.php similarity index 91% rename from backend/src/Sign/Controller/SignController.php rename to backend/src/Controller/SignController.php index 063911d..dc29851 100644 --- a/backend/src/Sign/Controller/SignController.php +++ b/backend/src/Controller/SignController.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace App\Sign\Controller; +namespace App\Controller; -use App\Sign\Api\Request\SignRequest; -use App\Sign\SignService; +use App\Api\Request\SignRequest; +use App\SignService; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Exception\AccessDeniedException; class SignController extends AbstractController diff --git a/backend/src/Entity/.gitignore b/backend/src/Entity/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/backend/src/Repository/.gitignore b/backend/src/Repository/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/backend/src/Sign/SignService.php b/backend/src/SignService.php similarity index 96% rename from backend/src/Sign/SignService.php rename to backend/src/SignService.php index a0a352f..d7f5ecf 100644 --- a/backend/src/Sign/SignService.php +++ b/backend/src/SignService.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App\Sign; +namespace App; +use App\Api\Api; +use App\Api\ApiParams; use App\Infrastructure\External\Api\BinaryStringFileResult; -use App\Sign\Api\Api; -use App\Sign\Api\ApiParams; use Exception; use RuntimeException; -- 2.40.1 From e42e611f295ad4c8f55421396b77898db932848f Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 11 Oct 2024 17:25:47 +0400 Subject: [PATCH 03/22] =?UTF-8?q?TD-322:=20[BACK].=20[=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B8=D1=81=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9=D0=BD=D0=B5=D1=80=D0=B5=20?= =?UTF-8?q?signer]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 25 ++++- .idea/.gitignore | 8 -- .idea/codeception.xml | 18 ---- .idea/git_toolbox_blame.xml | 6 -- .idea/modules.xml | 8 -- .idea/php.xml | 113 ---------------------- .idea/phpspec.xml | 16 --- .idea/phpunit.xml | 10 -- .idea/signer.iml | 95 ------------------ .idea/vcs.xml | 6 -- backend/src/Controller/SignController.php | 2 +- 11 files changed, 25 insertions(+), 282 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/codeception.xml delete mode 100644 .idea/git_toolbox_blame.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/php.xml delete mode 100644 .idea/phpspec.xml delete mode 100644 .idea/phpunit.xml delete mode 100644 .idea/signer.iml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index bf7460d..469d302 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,26 @@ .DS_Store .vscode -.idea +/.idea/ +/.phpunit.cache +/node_modules +/public/build +/public/hot +/public/storage +/storage/*.key +/vendor +.env +.env.backup +.env.production +.phpactor.json +.phpunit.result.cache +Homestead.json +Homestead.yaml +auth.json +npm-debug.log +yarn-error.log +/.fleet +/.idea +/.vscode +/.php-cs-fixer.php +/.php-cs-fixer.cache +.php_cs.cache diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/codeception.xml b/.idea/codeception.xml deleted file mode 100644 index 4a9baa3..0000000 --- a/.idea/codeception.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/git_toolbox_blame.xml b/.idea/git_toolbox_blame.xml deleted file mode 100644 index 7dc1249..0000000 --- a/.idea/git_toolbox_blame.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 696bfed..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index 6eba0e8..0000000 --- a/.idea/php.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/phpspec.xml b/.idea/phpspec.xml deleted file mode 100644 index 4311520..0000000 --- a/.idea/phpspec.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml deleted file mode 100644 index aacfcdb..0000000 --- a/.idea/phpunit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/signer.iml b/.idea/signer.iml deleted file mode 100644 index 21140ef..0000000 --- a/.idea/signer.iml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/backend/src/Controller/SignController.php b/backend/src/Controller/SignController.php index dc29851..84e72f1 100644 --- a/backend/src/Controller/SignController.php +++ b/backend/src/Controller/SignController.php @@ -22,7 +22,7 @@ class SignController extends AbstractController ){ } - #[Route(path: '/sign', name: 'app.test', methods: ['POST'])] + #[Route(path: '/sign', name: 'app.sign', methods: ['POST'])] public function __invoke(Request $request, SignRequest $signRequest): Response { if ($signRequest->apiKey !== self::API_KEY) { -- 2.40.1 From 74f3a069f01ae64bfb71cb1226ed3761e3ef16b6 Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 11 Oct 2024 17:41:06 +0400 Subject: [PATCH 04/22] =?UTF-8?q?TD-322:=20[BACK].=20[=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B8=D1=81=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9=D0=BD=D0=B5=D1=80=D0=B5=20?= =?UTF-8?q?signer]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/Api/Request/SignRequest.php | 1 - backend/src/Controller/SignController.php | 6 ------ 2 files changed, 7 deletions(-) diff --git a/backend/src/Api/Request/SignRequest.php b/backend/src/Api/Request/SignRequest.php index d0c20af..ec12392 100644 --- a/backend/src/Api/Request/SignRequest.php +++ b/backend/src/Api/Request/SignRequest.php @@ -10,5 +10,4 @@ class SignRequest implements RequestDtoInterface { public string $url; public int $batch; - public string $apiKey; } \ No newline at end of file diff --git a/backend/src/Controller/SignController.php b/backend/src/Controller/SignController.php index 84e72f1..4d0e071 100644 --- a/backend/src/Controller/SignController.php +++ b/backend/src/Controller/SignController.php @@ -15,8 +15,6 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException; class SignController extends AbstractController { - private const string API_KEY = 'ldskfjhgsdkl;ftghwerot239845yjsdknbgedklhhg'; - public function __construct( private readonly SignService $signService ){ @@ -25,10 +23,6 @@ class SignController extends AbstractController #[Route(path: '/sign', name: 'app.sign', methods: ['POST'])] public function __invoke(Request $request, SignRequest $signRequest): Response { - if ($signRequest->apiKey !== self::API_KEY) { - throw new AccessDeniedException('доступ запрещен'); - } - $token = $request->server->get('HTTP_AUTHORIZATION'); return new JsonResponse($this->signService->signDocument($signRequest->url, $token, $signRequest->batch)); -- 2.40.1 From 98960711732aeea4eaa7fe86d22d8bdf89271bf9 Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 11 Oct 2024 17:41:39 +0400 Subject: [PATCH 05/22] =?UTF-8?q?TD-322:=20[BACK].=20[=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B8=D1=81=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9=D0=BD=D0=B5=D1=80=D0=B5=20?= =?UTF-8?q?signer]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/Controller/SignController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/Controller/SignController.php b/backend/src/Controller/SignController.php index 4d0e071..4bc52cc 100644 --- a/backend/src/Controller/SignController.php +++ b/backend/src/Controller/SignController.php @@ -11,7 +11,6 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\Exception\AccessDeniedException; class SignController extends AbstractController { -- 2.40.1 From c0e5d795b887d238468dbac73d8229cfd183c752 Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 11 Oct 2024 18:19:53 +0400 Subject: [PATCH 06/22] =?UTF-8?q?TD-322:=20[BACK].=20[=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B8=D1=81=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9=D0=BD=D0=B5=D1=80=D0=B5=20?= =?UTF-8?q?signer]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/Api/Api.php | 45 ++++++++++++++++----------------- backend/src/DevSignService.php | 13 ++++++++++ backend/src/ProdSignService.php | 16 ++++++++++++ backend/src/SignService.php | 22 ++++++---------- 4 files changed, 59 insertions(+), 37 deletions(-) create mode 100644 backend/src/DevSignService.php create mode 100644 backend/src/ProdSignService.php diff --git a/backend/src/Api/Api.php b/backend/src/Api/Api.php index 5ceef4d..adf5cc9 100644 --- a/backend/src/Api/Api.php +++ b/backend/src/Api/Api.php @@ -11,35 +11,34 @@ use GuzzleHttp\RequestOptions; class Api extends AbstractApi { - private const string TYPE_OTHER = 'other'; - private const string API_DOCUMENT = '/api/v1/document/upload/batch/'; public ApiParams $apiParams; - public function send(string $url, string $token, $urlDocument, int $batch): array + public function send(string $token, string $path, int $batch): array { - $headers = [ - 'Accept' => 'application/json', - 'Authorization' => $token, - ]; - $options = [ - 'multipart' => [ - [ - 'name' => 'type', - 'contents' => self::TYPE_OTHER - ], + $params = [ + RequestOptions::HEADERS => [ + 'Authorization' => $token, + 'Accept' => 'application/json', + ], + RequestOptions::MULTIPART => [ [ 'name' => 'file', - 'contents' => fopen($urlDocument, 'r'), - 'filename' => 'sign_attorney.pdf', - 'headers' => [ - 'Content-Type' => '' - ] - ] - ]]; - $request = new Request('POST', sprintf('%s%s%s', $url, self::API_DOCUMENT, $batch), $headers); - $res = $this->client->sendAsync($request, $options)->wait(); + 'contents' => fopen($path, 'r'), + 'filename' => $path, + 'headers' => [ + 'Content-Type' => '', + ], + ], + [ + 'name' => 'type', + 'contents' => 'other' + ], + ], + ]; - return $this->responseHandler->setResponse($res)->getContentJsonToArray(); + $response = $this->client->post(sprintf('%s%s%s', $this->apiParams->endPointUrl, '/api/v1/document/upload/batch/', $batch), $params); + + return $this->responseHandler->setResponse($response)->getContentJsonToArray(); } public function download(string $url, string $token): BinaryStringFileResult diff --git a/backend/src/DevSignService.php b/backend/src/DevSignService.php new file mode 100644 index 0000000..d9a8dc8 --- /dev/null +++ b/backend/src/DevSignService.php @@ -0,0 +1,13 @@ +devSignService = new DevSignService(); + $this->prodSignService = new ProdSignService(); } public function signDocument(string $url, string $token, int $batch): array { @@ -26,7 +31,7 @@ class SignService $this->sign($document->tempFileName); - $response = $this->api->send($this->apiParams->endPointUrl, $token, $document->tempFileName . '_sign.pdf', $batch); + $response = $this->api->send($token, $document->tempFileName . '_sign.pdf', $batch); $this->removeExistingDocument($document); @@ -39,22 +44,11 @@ class SignService private function sign (string $documentUrl): void { match ($_ENV['APP_ENV']) { - 'dev' => $this->signDev($documentUrl), - 'prod' => $this->signProd($documentUrl), + 'dev' => $this->devSignService->sign($documentUrl), + 'prod' => $this->prodSignService->sign($documentUrl), }; } - private function signDev(string $documentUrl): void - { - exec(sprintf('cp %s %s_sign.pdf', $documentUrl, $documentUrl)); - } - - private function signProd(string $documentUrl): void - { - exec(sprintf('cp %s %s.pdf', $documentUrl, $documentUrl)); - exec(sprintf('pdfcpro sign /mnt/t/%s.pdf -out /mnt/t/%s_sign.pdf -cert ${SHA} -text "\n\t\tПодписано ЭП\n\t\t{subject/cn}\n\t\tСертификат {sha1}\n\t\tДействителен от {since} до {until}\n\t\tДата {date}\n\t\t{subject/t}\n\t\t{subject/fullname}\n\t\t" -fontfile /usr/local/share/fonts/Inter-Bold.ttf -fontsize 8 -x 2 -y 2 -w 96 -h 9', $documentUrl, $documentUrl)); - } - private function removeExistingDocument(BinaryStringFileResult $document): void { if (file_exists($document->tempFileName)) { -- 2.40.1 From 61d15604645996b18eedf04814b35ee841864060 Mon Sep 17 00:00:00 2001 From: cherednik Date: Mon, 14 Oct 2024 11:08:37 +0400 Subject: [PATCH 07/22] =?UTF-8?q?TD-322:=20[BACK].=20[=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B8=D1=81=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9=D0=BD=D0=B5=D1=80=D0=B5=20?= =?UTF-8?q?signer]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c14e619..798f5a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,8 +68,8 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 RUN composer install RUN service php8.3-fpm start -#COPY entrypoint.sh /entrypoint.sh -# -#ENTRYPOINT [ "/entrypoint.sh" ] +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] CMD ["php-fpm8.3", "-F"] EXPOSE 9000 \ No newline at end of file -- 2.40.1 From 8040aa1fd823a4d887247380c9c32ce15a899eeb Mon Sep 17 00:00:00 2001 From: cherednik Date: Mon, 14 Oct 2024 11:10:23 +0400 Subject: [PATCH 08/22] =?UTF-8?q?TD-322:=20[BACK].=20[=D1=80=D0=B5=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B8=D1=81=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9=D0=BD=D0=B5=D1=80=D0=B5=20?= =?UTF-8?q?signer]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 798f5a5..7d93f72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,4 +72,5 @@ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT [ "/entrypoint.sh" ] CMD ["php-fpm8.3", "-F"] + EXPOSE 9000 \ No newline at end of file -- 2.40.1 From 8c47dfa2857db364ea17f9ea80b28504246c23e1 Mon Sep 17 00:00:00 2001 From: cherednik Date: Thu, 17 Oct 2024 15:13:26 +0400 Subject: [PATCH 09/22] add api token --- backend/.env | 4 +++- backend/src/Api/Request/SignRequest.php | 1 + backend/src/Controller/SignController.php | 2 +- backend/src/SignService.php | 12 +++++++++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/.env b/backend/.env index cdccb51..5784151 100644 --- a/backend/.env +++ b/backend/.env @@ -10,4 +10,6 @@ APP_SECRET=850da55654c68f779822ea80d2b66a94 # DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8" ###< doctrine/doctrine-bundle ### -DOT_DOT_URL='http://dot-dot.local' \ No newline at end of file +DOT_DOT_URL='http://dot-dot.local' + +API_TOKEN='secret' \ No newline at end of file diff --git a/backend/src/Api/Request/SignRequest.php b/backend/src/Api/Request/SignRequest.php index ec12392..f3e6193 100644 --- a/backend/src/Api/Request/SignRequest.php +++ b/backend/src/Api/Request/SignRequest.php @@ -10,4 +10,5 @@ class SignRequest implements RequestDtoInterface { public string $url; public int $batch; + public string $apiToken; } \ No newline at end of file diff --git a/backend/src/Controller/SignController.php b/backend/src/Controller/SignController.php index 4bc52cc..c7822b7 100644 --- a/backend/src/Controller/SignController.php +++ b/backend/src/Controller/SignController.php @@ -24,6 +24,6 @@ class SignController extends AbstractController { $token = $request->server->get('HTTP_AUTHORIZATION'); - return new JsonResponse($this->signService->signDocument($signRequest->url, $token, $signRequest->batch)); + return new JsonResponse($this->signService->signDocument($signRequest, $token)); } } \ No newline at end of file diff --git a/backend/src/SignService.php b/backend/src/SignService.php index 6c427df..5a3b44e 100644 --- a/backend/src/SignService.php +++ b/backend/src/SignService.php @@ -6,9 +6,11 @@ namespace App; use App\Api\Api; use App\Api\ApiParams; +use App\Api\Request\SignRequest; use App\Infrastructure\External\Api\BinaryStringFileResult; use Exception; use RuntimeException; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; class SignService { @@ -22,16 +24,20 @@ class SignService $this->devSignService = new DevSignService(); $this->prodSignService = new ProdSignService(); } - public function signDocument(string $url, string $token, int $batch): array + public function signDocument(SignRequest $request,string $token): array { + if ($_ENV['API_TOKEN'] !== $request->apiToken) { + throw new AccessDeniedHttpException('Доступ запрещен'); + } + $this->api->apiParams = $this->apiParams; try { - $document = $this->api->download($url, $token); + $document = $this->api->download($request->url, $token); $this->sign($document->tempFileName); - $response = $this->api->send($token, $document->tempFileName . '_sign.pdf', $batch); + $response = $this->api->send($token, $document->tempFileName . '_sign.pdf', $request->batch); $this->removeExistingDocument($document); -- 2.40.1 From 3caecf7674ea854ea96236868ebea5ff546eed99 Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 18 Oct 2024 18:47:32 +0400 Subject: [PATCH 10/22] fix type document --- backend/src/Api/Api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/Api/Api.php b/backend/src/Api/Api.php index adf5cc9..0ad4285 100644 --- a/backend/src/Api/Api.php +++ b/backend/src/Api/Api.php @@ -31,7 +31,7 @@ class Api extends AbstractApi ], [ 'name' => 'type', - 'contents' => 'other' + 'contents' => 'attorney-signed' ], ], ]; -- 2.40.1 From 38f43978db3ccd8b097b79d75a8c22b4e8ea0200 Mon Sep 17 00:00:00 2001 From: cherednik Date: Mon, 21 Oct 2024 14:19:12 +0400 Subject: [PATCH 11/22] new license key --- license.key | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/license.key b/license.key index e578514..567481f 100644 --- a/license.key +++ b/license.key @@ -1,22 +1,22 @@ -----BEGIN PGP MESSAGE----- -owGbwMvMwMX4m2NrnreKjyDj6QN7khjSNt7+XK1UllpUnJmfp2SloGSopKOglJOZ -nJpXnArmJxmkmBmaJukamRpY6pqYp5noJqYkJeomWViamCdZmqYYGIG1FBTlp5Qm -l4C05GeX5iQW6RanFgHNRZKLR7IGJJyXmAu2IqbUwMTICEQap4JIE3MwOxFMGuji -l1YAUYZJCGljYzBpAVZqCCaNECIwbSD7U3MTM3NADsjLL07Ny853yCzRS8kv0QVi -vaJSkIriksSikmKQEiMDIxNdAwtdA7MQAwMrMIoCm1FRkFmUiqTEEqTEyNjK1BKI -wErySnOTUovi89PiocEKUm1Y28lkzMLAyMUgK6bIskDMKPAlS1X1ul379sDih5UJ -FDcMXJwCMJFVJvz/naTc7D4zPFV0Z8rd1HWtvfZuBsenCs1DXVpJ919fN5DamxEc -tPnJWy3X4JuP9+nsCIqXz1d4ofrd/NS7KB5RbX9Bxg9bV075eMOBsbLysJPOnnn9 -FbFf9nJ1bdro06nlmm0sHHx/UcHXDgbz1qcKcttnmZnxP81h19XzrZ5r4K27p3fm -4WbOdc+v56twRPJef5r+3znp3eLSWqsOtYZgy6vdRzcEJa18Yai76U/ODt2Nfw/x -7HTX2vvxa9Wcqo1pO/2P+kx3f3GTbXeyQUfVnb9FCyfm28kb/K7/76+hnuH3dvvU -feXvjJ7Oys9Sm3ybdd6HoBk3I3utbr/5YLM63zIoML3pYJX2izNLQ07tPfRg4u9t -J/iT//BGPF3zm3nb/hXimerFpxbsbg5cGZkfJR8n0rXE55yr/JV9mmohf4QPS2uX -nLLzerB4/1cz9s1Ca6Z/2OtnInHMhpXvxTNJpc5lcRe7e5q7+WUvGHSHPUjNeSQe -qSc7q5sxd/qBc82v5M0f9Eeqma5qP7nzgqZ55QP7KWKt51h6y/2PXemtO88sbF1r -GMqf/69hto1qaFsdi7vJnpN32+3+/nuycvKDOYlPuT4mnde9xv5n4luLDfeu/Ki2 -6GDxLivKP2fqZlVXYp295veBA8U337gnX3RMa9nm2dnS/otHUKQnsmraLZl3Ducl -V57lnFC7XEyhi1lFsMcv7Ai/sbP5PAA= -=FMIf +owGbwMvMwMX4m2NrnreKjyDj6QP7kxjSmacbViuVpRYVZ+bnKVkpKBkq6Sgo5WQm +p+YVp4L4phZpFmmppmm6Binmqbom5kZmuhaGaYa6xklJiUaGZsZGFsZmIC0FRfkp +pcklIC352aU5iUW6KanF2SX5BUiS8Uj2GIEtykvMBdsSU2pgYmQEIo1TQaSJOZid +CCYNdPFLK4AowySEtLExmLQAKzUEk0YIEZg2kP2puYmZOSAH5OUXp+Zl5ztkluil +5JfoArFeUSlIRXFJYlFJMdjFBkYmuoYGugbmIQYGVmAUBTajoiCzKBVJiaGugWWI +kbGVqSUQgZXkleYmpRbF56fFQ0MWpNqwtpPJmIWBkYtBVkyRZYGYUeBLlqrqdbv2 +7YFFESsTKHoYuDgF4CL3+f/76d+J9z6/TjVzBkMtT2opR1L/Pp+JpjeEMjv5botm +i+ncWXnK/7kb9zwDM1mmfR8rbmUlt+rHnr7zO8Wwcr/8kw2LD77+JPtYnZ1tH6vT +josyV3bumy6jKmR6NGj11jbGrL01OfHymks0byscernsdP7fT1NcS7nOhVSvnaV1 +7cvZ7B/mGz5GcCSxbdmyYEJbe5ngKWulCdMWf4lasbToxPVma//DKgzX5rG0T/kQ +8uba/MX5e9jcJW+e3uP41VHx65d7J5MqWH+dkco4eVL2+M+Z7JG5DmtkmU52Mt3/ +JrChvXXZbDem/DArv3uGbOocZc77TU4/ku14KW1/lVHz68S+oM07pXYnMMvcMLvb +23NYXmmBos9XQdWoH63MEjyRhcvW3v54UbP2ftN8v1a2nblab3N8256k+N5avXdB +0603RTsXTPkvJ1J99YipVGFH4TsjxtyZEUsUzZOWnn7r/+3LIj8Zbx8+kanJQfGn +P7oX/OEV+PV006GzzQsM3LL9tJ2X5tk/eHFrT9KbC53d32u5tTcf7lqW9CHcP6jR +68ke/10ZadO12K83/n63voxdViNq/lb3qDfa+xN9tLqfrv6lZGSxriub+dMbD7aq +VMFzFXf//k3QS9B+JdT162X5jjfrghd/Syu5vblzVVu5wIeSkIpll9eruckE/gmc +KblYtJn362Iucw7beVdnFmSI/nmTPuGm9ZaVT8oA +=JLZ9 -----END PGP MESSAGE----- -- 2.40.1 From c98fae646ae0fdc7b2c44e174eb9fd3425c39e44 Mon Sep 17 00:00:00 2001 From: cherednik Date: Mon, 21 Oct 2024 14:48:38 +0400 Subject: [PATCH 12/22] fix build docker --- Dockerfile | 2 +- entrypoint.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7d93f72..c81cb18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,7 +54,7 @@ RUN apt update && apt install -y okular-csp-utils RUN mkdir -p /root/.config COPY license.key /license.key -RUN pdfcpro install-license /license.key +RUN echo Y | pdfcpro install-license /license.key COPY Inter-Bold.ttf /usr/local/share/fonts/Inter-Bold.ttf RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer diff --git a/entrypoint.sh b/entrypoint.sh index d5bf05d..d2ff61d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -x -if [[ $SITE == "prod"]];then +if [[ $APP_ENV == "prod"]];then service pcscd start cert=$(/opt/cprocsp/bin/amd64/csptest -keyset -enum_cont -verifyc -fq | grep Aktiv | awk -F'00 00' '{print $2}' | tr -d '\\') /opt/cprocsp/bin/amd64/certmgr -inst -cont "${cert}" -store uMy -- 2.40.1 From 61c61d7df035a92720fb519a318f0bc67b326dd3 Mon Sep 17 00:00:00 2001 From: cherednik Date: Mon, 21 Oct 2024 19:34:24 +0400 Subject: [PATCH 13/22] =?UTF-8?q?DD-3510:=202.=20BACK.=20[=D0=94=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=B5=D0=BD=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20?= =?UTF-8?q?=D0=B2=D0=BE=D0=B4=D0=B8=D1=82=D0=B5=D0=BB=D1=8E]=20-=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=20=D0=9A=D0=AD?= =?UTF-8?q?=D0=9F=20=D0=B2=20=D1=80=D1=83=D1=87=D0=BD=D0=BE=D0=BC=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B6=D0=B8=D0=BC=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c81cb18..48f8555 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,9 +68,9 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 RUN composer install RUN service php8.3-fpm start -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT [ "/entrypoint.sh" ] +#COPY entrypoint.sh /entrypoint.sh +# +#ENTRYPOINT [ "/entrypoint.sh" ] CMD ["php-fpm8.3", "-F"] EXPOSE 9000 \ No newline at end of file -- 2.40.1 From 544302140b9846715b4fb1c39dda6ed92148b4dd Mon Sep 17 00:00:00 2001 From: cherednik Date: Tue, 22 Oct 2024 16:36:12 +0400 Subject: [PATCH 14/22] fix entrypoint.sh --- Dockerfile | 6 +++--- entrypoint.sh | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 48f8555..c81cb18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,9 +68,9 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 RUN composer install RUN service php8.3-fpm start -#COPY entrypoint.sh /entrypoint.sh -# -#ENTRYPOINT [ "/entrypoint.sh" ] +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] CMD ["php-fpm8.3", "-F"] EXPOSE 9000 \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index d2ff61d..b56eb29 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,12 +1,14 @@ -#!/bin/bash -x +#!/bin/bash -x -if [[ $APP_ENV == "prod"]];then +APP_ENV=$(grep APP_ENV $DIRECTORY".env.local" | xargs) + +if [[ ${APP_ENV#*=} == "prod" ]]; then service pcscd start cert=$(/opt/cprocsp/bin/amd64/csptest -keyset -enum_cont -verifyc -fq | grep Aktiv | awk -F'00 00' '{print $2}' | tr -d '\\') /opt/cprocsp/bin/amd64/certmgr -inst -cont "${cert}" -store uMy certmgr -list -store umy SHA=$(certmgr -list -store umy | grep SHA | awk -F':' '{print $2}' | tr -d ' ') -fi +fi # pdfcpro sign /mnt/t/123.pdf -out /mnt/t/123_sign.pdf -cert ${SHA} -text "\n\t\tПодписано ЭП\n\t\t{subject/cn}\n\t\tСертификат {sha1}\n\t\tДействителен от {since} до {until}\n\t\tДата {date}\n\t\t{subject/t}\n\t\t{subject/fullname}\n\t\t" -fontfile /usr/local/share/fonts/Inter-Bold.ttf -fontsize 8 -x 2 -y 2 -w 96 -h 9 -- 2.40.1 From c20da7d0955d28678047eb7f32d67f7a55c31b2a Mon Sep 17 00:00:00 2001 From: cherednik Date: Thu, 24 Oct 2024 14:35:44 +0400 Subject: [PATCH 15/22] fix dockerfile and entrypoint --- Dockerfile | 2 +- entrypoint.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c81cb18..3c0e1f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ RUN apt update && apt install -y \ libonig-dev \ libxslt1-dev \ acl \ - && echo 'alias sf="php bin/console"' >> ~/.bashrc \ + && echo 'alias sf="php bin/console"' >> ~/.bashrc RUN wget -q -O /etc/apt/trusted.gpg.d/lab50.gpg http://packages.lab50.net/lab50.gpg RUN echo 'deb http://packages.lab50.net/okular jammy main non-free' > /etc/apt/sources.list.d/okulargost.list diff --git a/entrypoint.sh b/entrypoint.sh index b56eb29..ea79d1b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -x -APP_ENV=$(grep APP_ENV $DIRECTORY".env.local" | xargs) +APP_ENV="${APP_ENV:-dev}” if [[ ${APP_ENV#*=} == "prod" ]]; then service pcscd start -- 2.40.1 From f22707ffe2e2d4e9f32f6613e84211fbe035aff4 Mon Sep 17 00:00:00 2001 From: cherednik Date: Thu, 24 Oct 2024 14:49:52 +0400 Subject: [PATCH 16/22] fix entrypoint --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index ea79d1b..2d80d18 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -x -APP_ENV="${APP_ENV:-dev}” +APP_ENV="${APP_ENV:-dev}" if [[ ${APP_ENV#*=} == "prod" ]]; then service pcscd start -- 2.40.1 From e584fea171f725243654f0fe92b755619f32b652 Mon Sep 17 00:00:00 2001 From: cherednik Date: Thu, 24 Oct 2024 15:17:46 +0400 Subject: [PATCH 17/22] fix entrypoint --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index 3c0e1f7..6453fa9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,6 +64,9 @@ COPY ./backend /usr/src/signer COPY ./docker/php/www.conf /etc/php/8.3/fpm/pool.d/www.conf +RUN curl curl https://frankenphp.dev/install.sh | sh +RUN mv /usr/src/signer/frankenphp /usr/local/bin/ + ENV COMPOSER_ALLOW_SUPERUSER=1 RUN composer install RUN service php8.3-fpm start @@ -72,5 +75,6 @@ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT [ "/entrypoint.sh" ] CMD ["php-fpm8.3", "-F"] +CMD ["frankenphp php-server --listen 0.0.0.0:8000 ./public"] EXPOSE 9000 \ No newline at end of file -- 2.40.1 From 436a7cd2e0fe97c31ea26369f2467f5c1b35b63d Mon Sep 17 00:00:00 2001 From: cherednik Date: Thu, 24 Oct 2024 15:21:56 +0400 Subject: [PATCH 18/22] fix entrypoint --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6453fa9..41d2366 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,6 +75,5 @@ COPY entrypoint.sh /entrypoint.sh ENTRYPOINT [ "/entrypoint.sh" ] CMD ["php-fpm8.3", "-F"] -CMD ["frankenphp php-server --listen 0.0.0.0:8000 ./public"] EXPOSE 9000 \ No newline at end of file -- 2.40.1 From 4b14caf08b495cab80ccb87ebe73f44f8607c55d Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 25 Oct 2024 14:16:49 +0400 Subject: [PATCH 19/22] fix SHA --- backend/src/ProdSignService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/ProdSignService.php b/backend/src/ProdSignService.php index 6274c35..7823f6d 100644 --- a/backend/src/ProdSignService.php +++ b/backend/src/ProdSignService.php @@ -11,6 +11,6 @@ class ProdSignService public function sign(string $documentUrl): void { exec(sprintf('cp %s %s.pdf', $documentUrl, $documentUrl)); - exec(sprintf('pdfcpro sign /mnt/t/%s.pdf -out /mnt/t/%s_sign.pdf -cert ${SHA} -text "\n\t\tПодписано ЭП\n\t\t{subject/cn}\n\t\tСертификат {sha1}\n\t\tДействителен от {since} до {until}\n\t\tДата {date}\n\t\t{subject/t}\n\t\t{subject/fullname}\n\t\t" -fontfile /usr/local/share/fonts/Inter-Bold.ttf -fontsize 8 -x 2 -y 2 -w 96 -h 9', $documentUrl, $documentUrl)); + exec(sprintf('pdfcpro sign /mnt/t/%s.pdf -out /mnt/t/%s_sign.pdf -cert cbfc28b024316bfe43066008cae177713533a6dd -text "\n\t\tПодписано ЭП\n\t\t{subject/cn}\n\t\tСертификат {sha1}\n\t\tДействителен от {since} до {until}\n\t\tДата {date}\n\t\t{subject/t}\n\t\t{subject/fullname}\n\t\t" -fontfile /usr/local/share/fonts/Inter-Bold.ttf -fontsize 8 -x 2 -y 2 -w 96 -h 9', $documentUrl, $documentUrl)); } } \ No newline at end of file -- 2.40.1 From ce4d3649d77410ddb8503435ed049db69a5ccf59 Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 25 Oct 2024 16:33:14 +0400 Subject: [PATCH 20/22] fix license.key --- license.key | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/license.key b/license.key index 567481f..1c81c64 100644 --- a/license.key +++ b/license.key @@ -1,22 +1,22 @@ -----BEGIN PGP MESSAGE----- -owGbwMvMwMX4m2NrnreKjyDj6QP7kxjSmacbViuVpRYVZ+bnKVkpKBkq6Sgo5WQm -p+YVp4L4phZpFmmppmm6Binmqbom5kZmuhaGaYa6xklJiUaGZsZGFsZmIC0FRfkp -pcklIC352aU5iUW6KanF2SX5BUiS8Uj2GIEtykvMBdsSU2pgYmQEIo1TQaSJOZid -CCYNdPFLK4AowySEtLExmLQAKzUEk0YIEZg2kP2puYmZOSAH5OUXp+Zl5ztkluil -5JfoArFeUSlIRXFJYlFJMdjFBkYmuoYGugbmIQYGVmAUBTajoiCzKBVJiaGugWWI -kbGVqSUQgZXkleYmpRbF56fFQ0MWpNqwtpPJmIWBkYtBVkyRZYGYUeBLlqrqdbv2 -7YFFESsTKHoYuDgF4CL3+f/76d+J9z6/TjVzBkMtT2opR1L/Pp+JpjeEMjv5botm -i+ncWXnK/7kb9zwDM1mmfR8rbmUlt+rHnr7zO8Wwcr/8kw2LD77+JPtYnZ1tH6vT -josyV3bumy6jKmR6NGj11jbGrL01OfHymks0byscernsdP7fT1NcS7nOhVSvnaV1 -7cvZ7B/mGz5GcCSxbdmyYEJbe5ngKWulCdMWf4lasbToxPVma//DKgzX5rG0T/kQ -8uba/MX5e9jcJW+e3uP41VHx65d7J5MqWH+dkco4eVL2+M+Z7JG5DmtkmU52Mt3/ -JrChvXXZbDem/DArv3uGbOocZc77TU4/ku14KW1/lVHz68S+oM07pXYnMMvcMLvb -23NYXmmBos9XQdWoH63MEjyRhcvW3v54UbP2ftN8v1a2nblab3N8256k+N5avXdB -0603RTsXTPkvJ1J99YipVGFH4TsjxtyZEUsUzZOWnn7r/+3LIj8Zbx8+kanJQfGn -P7oX/OEV+PV006GzzQsM3LL9tJ2X5tk/eHFrT9KbC53d32u5tTcf7lqW9CHcP6jR -68ke/10ZadO12K83/n63voxdViNq/lb3qDfa+xN9tLqfrv6lZGSxriub+dMbD7aq -VMFzFXf//k3QS9B+JdT162X5jjfrghd/Syu5vblzVVu5wIeSkIpll9eruckE/gmc -KblYtJn362Iucw7beVdnFmSI/nmTPuGm9ZaVT8oA -=JLZ9 +owGbwMvMwMX4m2NrnreKjyDj6QN7khjSpXteViuVpRYVZ+bnKVkpKBkq6Sgo5WQm +p+YVp4L4ZhbmaakmSYm6BhaWqbomSamJupYpyca6aYYGScZJxsbJ5qmpIC0FRfkp +pcklIC352aU5iUW6xalFQHOR5OKRrAEJ5yXmgq2IKTUwMTICkcapINLEHMxOBJMG +uvilFUCUYRJC2tgYTFqAlRqCSSOECEwbyP7U3MTMHJAD8vKLU/Oy8x0yS/RS8kt0 +gVivqBSkorgksaikGKTEyMDIRNfQQNfINMTAwAqMosBmVBRkFqUiKTHUNTIJMTK2 +MrUEIrCSvNLcpNSi+Py0eGiwglQb1nYyGbMwMHIxyIopsiwQMwp8yVJVvW7Xvj2w ++GFlAsUNAxenAExk6QL+PxwK68QK1M50+n6+5/nqf67rlhvB1Yef7bh99zJzstHz +LSdsOD4ee3Ik5rf+FtaUfX+nGBpwGmrMb/IqOzC3VfN73/WFEgJb/s5ZocZguCI9 +aM214nT57238r+tcp/LOfrHoxLEt+j8V5rO17S65PaHVRr3Tv6th0icNiZJD3/er +pxtUmHzQKw7h22jIypd3bV3W5teZ04U68jbX3np0wOuZ/fdFB/fUzm2bvHzn2b6p +jJ7vt1WkLpz87dSD2ee47nx/MOUEa8cf3aN7Y+ten47zY/vieMFLSCD5Q9cMz8Kt +5bEJfP1AByw+qXEiLNqt8Mi2ig1MT76fKje6vlelXuH6iqtrpn/9Grx7xcWTDkdD +RF4bfJUzfHH1bsAqlxDL6pXvsxrDGZItzs+YtNPEYtXEzxGHA8vcW45M0lFaNyE9 +a9WTZcVZQVvCYk79nfktzmhiZ7voZqY6BqsD82/cPHjPTYA58dvKvNoK5jm2p3lc +i05nXhGwcPwz80H/tvglz1S3rlj1NuCniG7j+8Vn3pdpTdpksTfgqv3ujf4WRzu4 +CrWidbcJSRe+2FDD4tRmdydlDmPKNoGEKd+nZv4okAtaey6r8cixDzn3o/6d7XD3 +YjUP/uijsCBSvfiM7a0l+QuKJkzg/t7vv261S9LjMk/dSLYdxoZ3d3Lp+FZuDP0u +fnm1QWZSluMsx5972jPC+3d3zrjqXfnJ5Nt1XRYA +=UzI0 -----END PGP MESSAGE----- -- 2.40.1 From f6770484303b3613d348338d05d159a7f6fb8159 Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 25 Oct 2024 17:14:54 +0400 Subject: [PATCH 21/22] fix pdfcpro --- backend/src/ProdSignService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/ProdSignService.php b/backend/src/ProdSignService.php index 7823f6d..e8055b6 100644 --- a/backend/src/ProdSignService.php +++ b/backend/src/ProdSignService.php @@ -11,6 +11,6 @@ class ProdSignService public function sign(string $documentUrl): void { exec(sprintf('cp %s %s.pdf', $documentUrl, $documentUrl)); - exec(sprintf('pdfcpro sign /mnt/t/%s.pdf -out /mnt/t/%s_sign.pdf -cert cbfc28b024316bfe43066008cae177713533a6dd -text "\n\t\tПодписано ЭП\n\t\t{subject/cn}\n\t\tСертификат {sha1}\n\t\tДействителен от {since} до {until}\n\t\tДата {date}\n\t\t{subject/t}\n\t\t{subject/fullname}\n\t\t" -fontfile /usr/local/share/fonts/Inter-Bold.ttf -fontsize 8 -x 2 -y 2 -w 96 -h 9', $documentUrl, $documentUrl)); + exec(sprintf('pdfcpro sign /tmp/%s.pdf -out /tmp/%s_sign.pdf -cert cbfc28b024316bfe43066008cae177713533a6dd -text "\n\t\tПодписано ЭП\n\t\t{subject/cn}\n\t\tСертификат {sha1}\n\t\tДействителен от {since} до {until}\n\t\tДата {date}\n\t\t{subject/t}\n\t\t{subject/fullname}\n\t\t" -fontfile /usr/local/share/fonts/Inter-Bold.ttf -fontsize 8 -x 2 -y 2 -w 96 -h 9', $documentUrl, $documentUrl)); } } \ No newline at end of file -- 2.40.1 From 92c6fe3c7c3a2289eba4a48c580de815c25f8f0d Mon Sep 17 00:00:00 2001 From: cherednik Date: Fri, 25 Oct 2024 17:31:28 +0400 Subject: [PATCH 22/22] fix pdfcpro --- backend/src/ProdSignService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/ProdSignService.php b/backend/src/ProdSignService.php index e8055b6..3207646 100644 --- a/backend/src/ProdSignService.php +++ b/backend/src/ProdSignService.php @@ -11,6 +11,6 @@ class ProdSignService public function sign(string $documentUrl): void { exec(sprintf('cp %s %s.pdf', $documentUrl, $documentUrl)); - exec(sprintf('pdfcpro sign /tmp/%s.pdf -out /tmp/%s_sign.pdf -cert cbfc28b024316bfe43066008cae177713533a6dd -text "\n\t\tПодписано ЭП\n\t\t{subject/cn}\n\t\tСертификат {sha1}\n\t\tДействителен от {since} до {until}\n\t\tДата {date}\n\t\t{subject/t}\n\t\t{subject/fullname}\n\t\t" -fontfile /usr/local/share/fonts/Inter-Bold.ttf -fontsize 8 -x 2 -y 2 -w 96 -h 9', $documentUrl, $documentUrl)); + exec(sprintf('pdfcpro sign %s.pdf -out %s_sign.pdf -cert cbfc28b024316bfe43066008cae177713533a6dd -text "\n\t\tПодписано ЭП\n\t\t{subject/cn}\n\t\tСертификат {sha1}\n\t\tДействителен от {since} до {until}\n\t\tДата {date}\n\t\t{subject/t}\n\t\t{subject/fullname}\n\t\t" -fontfile /usr/local/share/fonts/Inter-Bold.ttf -fontsize 8 -x 2 -y 2 -w 96 -h 9', $documentUrl, $documentUrl)); } } \ No newline at end of file -- 2.40.1