From a29324270089580f1d4fbf60324d9e9f16eeee62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Andr=C3=A1s=20Horv=C3=A1th?= Date: Thu, 11 May 2023 09:57:05 +0200 Subject: [PATCH 1/7] Remove docker-compose producion file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tamás András Horváth --- docker-compose.production.yml | 62 ----------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 docker-compose.production.yml diff --git a/docker-compose.production.yml b/docker-compose.production.yml deleted file mode 100644 index 06c3572..0000000 --- a/docker-compose.production.yml +++ /dev/null @@ -1,62 +0,0 @@ -version: '3.5' - -services: - pdb: - image: mysql:5.7 - container_name: residential_meeting_db - command: --explicit_defaults_for_timestamp --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci - env_file: .env - expose: - - 33063 - ports: - - 33063:3306 - volumes: - - ./docker/data/mysql:/var/lib/mysql - - ./docker/config/mysql/mysql.cnf:/etc/mysql/conf.d/mysql.cnf - networks: - - proxy - - webapp: - build: - context: . - dockerfile: docker/config/webapp/Dockerfile - container_name: residential_meeting_webapp - expose: - - 9007 - volumes: - - .:/var/www/html - - ./docker/config/webapp/php/ini/limitation.ini:/usr/local/etc/php/conf.d/limitation.ini - - ./docker/config/webapp/php/ini/security.ini:/usr/local/etc/php/conf.d/security.ini - - ./docker/config/webapp/php/ini/upload.ini:/usr/local/etc/php/conf.d/upload.ini - - ./docker/config/webapp/php/ini/opcache.ini:/usr/local/etc/php/conf.d/opcache.ini - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost"] - interval: 1m30s - timeout: 10s - retries: 3 - env_file: .env - depends_on: - - pdb - networks: - - proxy - - nginx: - image: fphgov/nginx - container_name: residential_meeting_nginx - networks: - - proxy - expose: - - 80 - - 443 - volumes: - - ./docker/config/nginx:/etc/nginx/conf.d - - ./docker/data/nginx/logs:/var/log/nginx - - ./:/var/www/html - depends_on: - - pdb - - webapp - -networks: - proxy: - external: - name: proxy From ba7575e7ff83567996920530d07dc03ed78a4e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Andr=C3=A1s=20Horv=C3=A1th?= Date: Thu, 11 May 2023 09:57:41 +0200 Subject: [PATCH 2/7] Enable MySQL event_scheduler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tamás András Horváth --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index bb3bbbb..57cdf60 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: db: image: mysql:5.7 container_name: residential_meeting_db - command: --explicit_defaults_for_timestamp --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + command: --explicit_defaults_for_timestamp --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --event_scheduler=ON env_file: .env ports: - 3306:3306 From 59d6ca9c00fdaad9db88c08884cc735e1b72a54d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Andr=C3=A1s=20Horv=C3=A1th?= Date: Thu, 11 May 2023 20:35:12 +0200 Subject: [PATCH 3/7] Add new statistics handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tamás András Horváth --- .env.example | 2 + config/autoload/app.global.php | 5 +- config/autoload/dependencies.global.php | 5 +- config/routes.php | 5 ++ src/App/src/ConfigProvider.php | 2 + src/App/src/Entity/Question.php | 2 +- src/App/src/Entity/Vote.php | 8 ++- src/App/src/Handler/Stat/GetVoteHandler.php | 56 +++++++++++++++++++ .../Handler/Stat/GetVoteHandlerFactory.php | 18 ++++++ .../StatisticsAccountMiddleware.php | 37 ++++++++++++ .../StatisticsAccountMiddlewareFactory.php | 21 +++++++ src/App/src/Model/ExportCsvModelInterface.php | 10 ++++ src/App/src/Model/VoteExportModel.php | 51 +++++++++++++++++ src/App/src/Model/VoteExportModelFactory.php | 21 +++++++ src/App/src/Repository/VoteRepository.php | 43 -------------- 15 files changed, 236 insertions(+), 50 deletions(-) create mode 100644 src/App/src/Handler/Stat/GetVoteHandler.php create mode 100644 src/App/src/Handler/Stat/GetVoteHandlerFactory.php create mode 100644 src/App/src/Middleware/StatisticsAccountMiddleware.php create mode 100644 src/App/src/Middleware/StatisticsAccountMiddlewareFactory.php create mode 100644 src/App/src/Model/ExportCsvModelInterface.php create mode 100644 src/App/src/Model/VoteExportModel.php create mode 100644 src/App/src/Model/VoteExportModelFactory.php diff --git a/.env.example b/.env.example index 7f9616f..777c7c7 100644 --- a/.env.example +++ b/.env.example @@ -45,4 +45,6 @@ APP_NOTIFICATION_FORCE=false APP_EMAIL_TEMPLATE=/var/www/html/public/email +APP_STAT_TOKEN=_stat_token + RECAPTCHA_SECRET=_from_google_ diff --git a/config/autoload/app.global.php b/config/autoload/app.global.php index 42b598b..22572e0 100644 --- a/config/autoload/app.global.php +++ b/config/autoload/app.global.php @@ -20,6 +20,9 @@ 'newsletter' => [ 'url' => 'https://hirlevel.budapest.hu/subscr_api.php', 'limit' => 20, - ] + ], + 'stat' => [ + 'token' => getenv('APP_STAT_TOKEN') + ], ], ]; diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php index 78d21cb..0194367 100644 --- a/config/autoload/dependencies.global.php +++ b/config/autoload/dependencies.global.php @@ -22,8 +22,9 @@ Laminas\Db\Adapter\AdapterInterface::class => Laminas\Db\Adapter\AdapterServiceFactory::class, \Doctrine\ORM\EntityManagerInterface::class => \Roave\PsrContainerDoctrine\EntityManagerFactory::class, - App\Middleware\AuditMiddleware::class => App\Middleware\AuditMiddlewareFactory::class, - App\Middleware\AccountMiddleware::class => App\Middleware\AccountMiddlewareFactory::class, + App\Middleware\AuditMiddleware::class => App\Middleware\AuditMiddlewareFactory::class, + App\Middleware\AccountMiddleware::class => App\Middleware\AccountMiddlewareFactory::class, + App\Middleware\StatisticsAccountMiddleware::class => App\Middleware\StatisticsAccountMiddlewareFactory::class, \Middlewares\Recaptcha::class => App\Middleware\RecaptchaMiddlewareFactory::class, diff --git a/config/routes.php b/config/routes.php index 07dff92..4e70262 100644 --- a/config/routes.php +++ b/config/routes.php @@ -40,4 +40,9 @@ App\Middleware\AccountMiddleware::class, App\Handler\Vote\AddHandler::class ], 'app.api.vote'); + + $app->get('/app/api/stat/votes', [ + App\Middleware\StatisticsAccountMiddleware::class, + App\Handler\Stat\GetVoteHandler::class + ], 'app.api.stat.votes'); }; diff --git a/src/App/src/ConfigProvider.php b/src/App/src/ConfigProvider.php index dcdbb24..39fc9e4 100644 --- a/src/App/src/ConfigProvider.php +++ b/src/App/src/ConfigProvider.php @@ -42,6 +42,8 @@ public function getDependencies(): array Handler\Question\GetHandler::class => Handler\Question\GetHandlerFactory::class, Handler\Question\GetAllHandler::class => Handler\Question\GetAllHandlerFactory::class, Handler\Question\GetNavigationHandler::class => Handler\Question\GetNavigationHandlerFactory::class, + Handler\Stat\GetVoteHandler::class => Handler\Stat\GetVoteHandlerFactory::class, + Model\VoteExportModel::class => Model\VoteExportModelFactory::class, Service\AccountServiceInterface::class => Service\AccountServiceFactory::class, Service\MailQueueServiceInterface::class => Service\MailQueueServiceFactory::class, Service\UserServiceInterface::class => Service\UserServiceFactory::class, diff --git a/src/App/src/Entity/Question.php b/src/App/src/Entity/Question.php index 0f28b5d..136f3df 100644 --- a/src/App/src/Entity/Question.php +++ b/src/App/src/Entity/Question.php @@ -23,7 +23,7 @@ class Question implements QuestionInterface * @ORM\Column(name="id", type="integer", options={"unsigned"=true}) * @ORM\GeneratedValue(strategy="IDENTITY") * - * @Groups({"list", "option", "detail", "full_detail", "navigation"}) + * @Groups({"list", "option", "detail", "stat", "full_detail", "navigation"}) */ protected int $id; diff --git a/src/App/src/Entity/Vote.php b/src/App/src/Entity/Vote.php index f868836..6ac50f6 100644 --- a/src/App/src/Entity/Vote.php +++ b/src/App/src/Entity/Vote.php @@ -21,27 +21,29 @@ class Vote implements VoteInterface * @ORM\Column(name="id", type="integer", options={"unsigned"=true}) * @ORM\GeneratedValue(strategy="IDENTITY") * - * @Groups({"list", "option", "detail", "full_detail", "vote_list"}) + * @Groups({"list", "option", "stat", "detail", "full_detail", "vote_list"}) */ protected int $id; /** * @ORM\ManyToOne(targetEntity="Question", cascade={"persist"}) * @ORM\JoinColumn(name="question_id", referencedColumnName="id", nullable=true) + * + * @Groups({"stat", "full_detail"}) */ private Question $question; /** * @ORM\Column(name="answer", type="boolean", nullable=true) * - * @Groups({"full_detail"}) + * @Groups({"stat", "full_detail"}) */ private ?bool $answer; /** * @ORM\Column(name="zip_code", type="string") * - * @Groups({"full_detail"}) + * @Groups({"stat", "full_detail"}) */ private string $zipCode; diff --git a/src/App/src/Handler/Stat/GetVoteHandler.php b/src/App/src/Handler/Stat/GetVoteHandler.php new file mode 100644 index 0000000..209b925 --- /dev/null +++ b/src/App/src/Handler/Stat/GetVoteHandler.php @@ -0,0 +1,56 @@ +voteExportModel = $voteExportModel; + } + + public function handle(ServerRequestInterface $request): ResponseInterface + { + $exportData = $this->voteExportModel->getCsvData(); + + ob_start(); + ob_get_clean(); + + $stream = fopen('php://memory', 'wb+'); + + foreach ($exportData as $fields) { + fputcsv($stream, $fields, ";"); + } + + rewind($stream); + + $body = new Stream($stream); + + return new Response($body, 200, [ + 'Content-Type' => 'text/csv; charset=utf-8', + 'Content-Disposition' => "attachment; filename=\"votes.csv\"", + 'Content-Description' => 'File Transfer', + 'Pragma' => 'public', + 'Expires' => '0', + 'Cache-Control' => 'must-revalidate', + 'Content-Length' => strval($body->getSize()), + ]); + } +} diff --git a/src/App/src/Handler/Stat/GetVoteHandlerFactory.php b/src/App/src/Handler/Stat/GetVoteHandlerFactory.php new file mode 100644 index 0000000..19fa490 --- /dev/null +++ b/src/App/src/Handler/Stat/GetVoteHandlerFactory.php @@ -0,0 +1,18 @@ +get(VoteExportModel::class) + ); + } +} diff --git a/src/App/src/Middleware/StatisticsAccountMiddleware.php b/src/App/src/Middleware/StatisticsAccountMiddleware.php new file mode 100644 index 0000000..5c13d67 --- /dev/null +++ b/src/App/src/Middleware/StatisticsAccountMiddleware.php @@ -0,0 +1,37 @@ +accountService = $accountService; + } + + public function process( + ServerRequestInterface $request, + RequestHandlerInterface $handler + ): ResponseInterface { + $authCode = $request->getHeaderLine('Authorization'); + + if ($authCode !== $this->config['app']['stat']['token']) { + return new JsonResponse([ + 'message' => 'No authentication', + ], 401); + } + + return $handler->handle($request); + } +} diff --git a/src/App/src/Middleware/StatisticsAccountMiddlewareFactory.php b/src/App/src/Middleware/StatisticsAccountMiddlewareFactory.php new file mode 100644 index 0000000..e63a0b7 --- /dev/null +++ b/src/App/src/Middleware/StatisticsAccountMiddlewareFactory.php @@ -0,0 +1,21 @@ +has('config') ? $container->get('config') : []; + + return new StatisticsAccountMiddleware( + $config, + $container->get(AccountServiceInterface::class) + ); + } +} diff --git a/src/App/src/Model/ExportCsvModelInterface.php b/src/App/src/Model/ExportCsvModelInterface.php new file mode 100644 index 0000000..393fa0a --- /dev/null +++ b/src/App/src/Model/ExportCsvModelInterface.php @@ -0,0 +1,10 @@ +em = $em; + $this->voteRepository = $this->em->getRepository(Vote::class); + } + + public function getCsvData(): array + { + $votes = $this->voteRepository->findAll(); + + $exportData = []; + + $exportData[] = self::HEADER; + + foreach ($votes as $vote) { + $data = [ + $vote->getId(), + $vote->getQuestion()->getId(), + $vote->getAnswer(), + $vote->getZipCode() + ]; + + $exportData[] = $data; + } + + return $exportData; + } +} diff --git a/src/App/src/Model/VoteExportModelFactory.php b/src/App/src/Model/VoteExportModelFactory.php new file mode 100644 index 0000000..94ba307 --- /dev/null +++ b/src/App/src/Model/VoteExportModelFactory.php @@ -0,0 +1,21 @@ +get(EntityManagerInterface::class) + ); + } +} diff --git a/src/App/src/Repository/VoteRepository.php b/src/App/src/Repository/VoteRepository.php index 380c7ad..bef4bfb 100644 --- a/src/App/src/Repository/VoteRepository.php +++ b/src/App/src/Repository/VoteRepository.php @@ -4,51 +4,8 @@ namespace App\Repository; -use App\Entity\Campaign; -use App\Entity\Project; -use App\Entity\User; use Doctrine\ORM\EntityRepository; -use Doctrine\ORM\Query\Expr\Join; -use Throwable; class VoteRepository extends EntityRepository { - /** @return mixed|int */ - public function numberOfVotes(int $id) - { - $qb = $this->createQueryBuilder('v'); - - $qb - ->select('COUNT(1)') - ->where('v.project = :id') - ->setParameter('id', $id); - - try { - return (int) $qb->getQuery()->getSingleScalarResult(); - } catch (Throwable $th) { - } - - return 0; - } - - public function checkExistsVoteInCampaign(User $user, Campaign $campaign): bool - { - $qb = $this->createQueryBuilder('v') - ->select('COUNT(1)') - ->innerJoin(Project::class, 'p', Join::WITH, 'p.id = v.project') - ->innerJoin(Campaign::class, 'c', Join::WITH, 'c.id = p.campaign') - ->where('v.user = :user') - ->andWhere('c.id = :campaign') - ->setParameter('user', $user) - ->setParameter('campaign', $campaign); - - $result = $qb->getQuery()->getSingleScalarResult(); - - try { - return (int) $result > 0; - } catch (Throwable $th) { - } - - return false; - } } From e17e3884128cdd479c6fec52720f1a665322227e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Andr=C3=A1s=20Horv=C3=A1th?= Date: Thu, 11 May 2023 21:04:29 +0200 Subject: [PATCH 4/7] Add history endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tamás András Horváth --- config/routes.php | 5 ++ src/App/src/ConfigProvider.php | 2 + src/App/src/Entity/Stat.php | 72 +++++++++++++++++++ src/App/src/Entity/StatInterface.php | 22 ++++++ .../src/Handler/Stat/GetHistoryHandler.php | 56 +++++++++++++++ .../Handler/Stat/GetHistoryHandlerFactory.php | 18 +++++ src/App/src/Model/StatExportModel.php | 49 +++++++++++++ src/App/src/Model/StatExportModelFactory.php | 21 ++++++ src/App/src/Repository/StatRepository.php | 11 +++ 9 files changed, 256 insertions(+) create mode 100644 src/App/src/Entity/Stat.php create mode 100644 src/App/src/Entity/StatInterface.php create mode 100644 src/App/src/Handler/Stat/GetHistoryHandler.php create mode 100644 src/App/src/Handler/Stat/GetHistoryHandlerFactory.php create mode 100644 src/App/src/Model/StatExportModel.php create mode 100644 src/App/src/Model/StatExportModelFactory.php create mode 100644 src/App/src/Repository/StatRepository.php diff --git a/config/routes.php b/config/routes.php index 4e70262..52a614f 100644 --- a/config/routes.php +++ b/config/routes.php @@ -45,4 +45,9 @@ App\Middleware\StatisticsAccountMiddleware::class, App\Handler\Stat\GetVoteHandler::class ], 'app.api.stat.votes'); + + $app->get('/app/api/stat/history', [ + App\Middleware\StatisticsAccountMiddleware::class, + App\Handler\Stat\GetHistoryHandler::class + ], 'app.api.stat.history'); }; diff --git a/src/App/src/ConfigProvider.php b/src/App/src/ConfigProvider.php index 39fc9e4..3a4c095 100644 --- a/src/App/src/ConfigProvider.php +++ b/src/App/src/ConfigProvider.php @@ -43,7 +43,9 @@ public function getDependencies(): array Handler\Question\GetAllHandler::class => Handler\Question\GetAllHandlerFactory::class, Handler\Question\GetNavigationHandler::class => Handler\Question\GetNavigationHandlerFactory::class, Handler\Stat\GetVoteHandler::class => Handler\Stat\GetVoteHandlerFactory::class, + Handler\Stat\GetHistoryHandler::class => Handler\Stat\GetHistoryHandlerFactory::class, Model\VoteExportModel::class => Model\VoteExportModelFactory::class, + Model\StatExportModel::class => Model\StatExportModelFactory::class, Service\AccountServiceInterface::class => Service\AccountServiceFactory::class, Service\MailQueueServiceInterface::class => Service\MailQueueServiceFactory::class, Service\UserServiceInterface::class => Service\UserServiceFactory::class, diff --git a/src/App/src/Entity/Stat.php b/src/App/src/Entity/Stat.php new file mode 100644 index 0000000..33fa865 --- /dev/null +++ b/src/App/src/Entity/Stat.php @@ -0,0 +1,72 @@ +date; + } + + public function setDate(DateTime $date): void + { + $this->date = $date; + } + + public function getDay(): int + { + return $this->day; + } + + public function setDay(int $day): void + { + $this->day = $day; + } + + public function getCount(): int + { + return $this->count; + } + + public function setCount(int $count): void + { + $this->count = $count; + } +} diff --git a/src/App/src/Entity/StatInterface.php b/src/App/src/Entity/StatInterface.php new file mode 100644 index 0000000..42b8d95 --- /dev/null +++ b/src/App/src/Entity/StatInterface.php @@ -0,0 +1,22 @@ +statExportModel = $statExportModel; + } + + public function handle(ServerRequestInterface $request): ResponseInterface + { + $exportData = $this->statExportModel->getCsvData(); + + ob_start(); + ob_get_clean(); + + $stream = fopen('php://memory', 'wb+'); + + foreach ($exportData as $fields) { + fputcsv($stream, $fields, ";"); + } + + rewind($stream); + + $body = new Stream($stream); + + return new Response($body, 200, [ + 'Content-Type' => 'text/csv; charset=utf-8', + 'Content-Disposition' => "attachment; filename=\"votes.csv\"", + 'Content-Description' => 'File Transfer', + 'Pragma' => 'public', + 'Expires' => '0', + 'Cache-Control' => 'must-revalidate', + 'Content-Length' => strval($body->getSize()), + ]); + } +} diff --git a/src/App/src/Handler/Stat/GetHistoryHandlerFactory.php b/src/App/src/Handler/Stat/GetHistoryHandlerFactory.php new file mode 100644 index 0000000..1ba51e1 --- /dev/null +++ b/src/App/src/Handler/Stat/GetHistoryHandlerFactory.php @@ -0,0 +1,18 @@ +get(StatExportModel::class) + ); + } +} diff --git a/src/App/src/Model/StatExportModel.php b/src/App/src/Model/StatExportModel.php new file mode 100644 index 0000000..64f1d37 --- /dev/null +++ b/src/App/src/Model/StatExportModel.php @@ -0,0 +1,49 @@ +em = $em; + $this->statRepository = $this->em->getRepository(Stat::class); + } + + public function getCsvData(): array + { + $stats = $this->statRepository->findAll(); + + $exportData = []; + + $exportData[] = self::HEADER; + + foreach ($stats as $stat) { + $data = [ + $stat->getDate()->format('Y-m-d'), + $stat->getDay(), + $stat->getCount(), + ]; + + $exportData[] = $data; + } + + return $exportData; + } +} diff --git a/src/App/src/Model/StatExportModelFactory.php b/src/App/src/Model/StatExportModelFactory.php new file mode 100644 index 0000000..328eac9 --- /dev/null +++ b/src/App/src/Model/StatExportModelFactory.php @@ -0,0 +1,21 @@ +get(EntityManagerInterface::class) + ); + } +} diff --git a/src/App/src/Repository/StatRepository.php b/src/App/src/Repository/StatRepository.php new file mode 100644 index 0000000..0499d0a --- /dev/null +++ b/src/App/src/Repository/StatRepository.php @@ -0,0 +1,11 @@ + Date: Thu, 11 May 2023 21:13:03 +0200 Subject: [PATCH 5/7] Add new environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tamás András Horváth --- .github/workflows/release-develop.yaml | 1 + .github/workflows/release-prod.yaml | 1 + values.dev.yaml | 2 ++ values.prod.yaml | 2 ++ 4 files changed, 6 insertions(+) diff --git a/.github/workflows/release-develop.yaml b/.github/workflows/release-develop.yaml index 27433c1..acfabfa 100644 --- a/.github/workflows/release-develop.yaml +++ b/.github/workflows/release-develop.yaml @@ -131,3 +131,4 @@ jobs: --set env[10].value=${{ secrets.APP_EMAIL }} --set env[11].value="${{ secrets.APP_PHONE }}" --set env[13].value=${{ secrets.RECAPTCHA_SECRET }} + --set env[14].value=${{ secrets.APP_STAT_TOKEN }} diff --git a/.github/workflows/release-prod.yaml b/.github/workflows/release-prod.yaml index f58d18e..8b19f7b 100644 --- a/.github/workflows/release-prod.yaml +++ b/.github/workflows/release-prod.yaml @@ -128,3 +128,4 @@ jobs: --set env[10].value=${{ secrets.APP_EMAIL }} --set env[11].value="${{ secrets.APP_PHONE }}" --set env[13].value=${{ secrets.RECAPTCHA_SECRET }} + --set env[14].value=${{ secrets.APP_STAT_TOKEN }} diff --git a/values.dev.yaml b/values.dev.yaml index e7278ef..d345740 100644 --- a/values.dev.yaml +++ b/values.dev.yaml @@ -55,6 +55,8 @@ env: value: https://lakogyules.budapest.hu - name: RECAPTCHA_SECRET value: _from_google_ + - name: APP_STAT_TOKEN + value: "" - name: SMTP_CONNECTION_CONFIG_SSL value: "" - name: DB_PASSWORD diff --git a/values.prod.yaml b/values.prod.yaml index bbdec3a..fc4d3ff 100644 --- a/values.prod.yaml +++ b/values.prod.yaml @@ -55,6 +55,8 @@ env: value: https://lakogyules.budapest.hu - name: RECAPTCHA_SECRET value: _from_google_ + - name: APP_STAT_TOKEN + value: "" - name: SMTP_CONNECTION_CONFIG_SSL value: "" - name: DB_PASSWORD From 94329a65b4c2ebfd00e3f994e7d25d494cf4f67b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Andr=C3=A1s=20Horv=C3=A1th?= Date: Thu, 11 May 2023 21:15:53 +0200 Subject: [PATCH 6/7] Disable token if is empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tamás András Horváth --- src/App/src/Middleware/StatisticsAccountMiddleware.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/App/src/Middleware/StatisticsAccountMiddleware.php b/src/App/src/Middleware/StatisticsAccountMiddleware.php index 5c13d67..3fa7ba6 100644 --- a/src/App/src/Middleware/StatisticsAccountMiddleware.php +++ b/src/App/src/Middleware/StatisticsAccountMiddleware.php @@ -11,6 +11,8 @@ use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; +use function strlen; + class StatisticsAccountMiddleware implements MiddlewareInterface { public function __construct( @@ -26,7 +28,10 @@ public function process( ): ResponseInterface { $authCode = $request->getHeaderLine('Authorization'); - if ($authCode !== $this->config['app']['stat']['token']) { + if ( + $authCode !== $this->config['app']['stat']['token'] || + strlen($authCode) === 0 + ) { return new JsonResponse([ 'message' => 'No authentication', ], 401); From b5a8b2b2c7d1d0ccd770645bf64c4cbd28bd9f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Andr=C3=A1s=20Horv=C3=A1th?= Date: Fri, 12 May 2023 00:44:21 +0200 Subject: [PATCH 7/7] Add chmod MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tamás András Horváth --- docker/config/webapp/setup.sh | 1 + k8s/php/setup.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/docker/config/webapp/setup.sh b/docker/config/webapp/setup.sh index 2e22815..7b5ff7d 100644 --- a/docker/config/webapp/setup.sh +++ b/docker/config/webapp/setup.sh @@ -30,3 +30,4 @@ if [ $MODE = "production" ]; then fi mkdir -p data/cache/DoctrineEntityProxy +chmod 777 -R data/cache/DoctrineEntityProxy diff --git a/k8s/php/setup.sh b/k8s/php/setup.sh index 21f9dd9..925686f 100644 --- a/k8s/php/setup.sh +++ b/k8s/php/setup.sh @@ -26,3 +26,4 @@ if [ $MODE = "production" ]; then fi mkdir -p data/cache/DoctrineEntityProxy +chmod 777 -R data/cache/DoctrineEntityProxy