From 6e35888db631b5b3f3cc1cee9a2ab28552c3c2ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Sun, 5 Feb 2023 23:49:23 +0100
Subject: [PATCH] Nacteni citlivych dat z docker secrets

---
 VERSION   | 2 +-
 lib/PZ.pm | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/VERSION b/VERSION
index 005119b..437459c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.4.1
+2.5.0
diff --git a/lib/PZ.pm b/lib/PZ.pm
index 3fa671a..e972d36 100644
--- a/lib/PZ.pm
+++ b/lib/PZ.pm
@@ -5,8 +5,12 @@ use Mojo::Pg;
 use Mojo::Redis;
 use Mojolicious::Plugin::Authentication;
 use Net::OAuth2::Profile::WebServer;
+use File::Find;
+use Path::Tiny qw( path );
 use PZ::Schema;
 
+use constant SECRETS => '/run/secrets';
+
 sub startup {
     my $self = shift;
 
@@ -14,6 +18,9 @@ sub startup {
     my $cfg = $self->plugin('Config');
     $self->helper( cfg => sub { return $cfg; } );
 
+    # konfigurace z docker secrets (maji prednost!)
+    find(sub { $cfg->{$_} = path(SECRETS . "/$_")->slurp_utf8 }, SECRETS);
+
     # Podpis pro cookies
     $self->secrets($cfg->{session}{secrets});
 
-- 
GitLab