]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Move davical and Jerome's website passwords to secure location
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 15 Apr 2019 23:08:15 +0000 (01:08 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 15 Apr 2019 23:08:15 +0000 (01:08 +0200)
Related issue: https://git.immae.eu/mantisbt/view.php?id=122

nixops/modules/websites/ftp/jerome.nix
nixops/modules/websites/tools/dav/davical.nix
nixops/modules/websites/tools/dav/default.nix

index 199bfab2184295770229028c1448061905a174f8..218060f3f58fc30e35b4800948da17d0586b6df8 100644 (file)
@@ -29,8 +29,11 @@ in {
       domain = "naturaloutil.immae.eu";
     };
 
-    services.myPhpfpm.poolConfigs.jerome = let
-      configFile = pkgs.writeText "naturaloutil.inc.php" ''
+    deployment.keys."prod-naturaloutil" = {
+      destDir = "/run/keys/webapps";
+      user = "wwwrun";
+      group = "wwwrun";
+      text = ''
         <?php
         $mysql_user = '${env.mysql.user}' ;
         $mysql_server = '${env.mysql.host}' ;
@@ -44,8 +47,10 @@ in {
         '' else ""}
         $database = connect_db($db, $mysql_server, $mysql_base, $mysql_user, $mysql_password);
         ?>
-        '';
-      in ''
+      '';
+    };
+    services.myPhpfpm.serviceDependencies.jerome = [ "mysql.service" "prod-naturaloutil-key.service" ];
+    services.myPhpfpm.poolConfigs.jerome = ''
       listen = /run/phpfpm/naturaloutil.sock
       user = wwwrun
       group = wwwrun
@@ -56,8 +61,8 @@ in {
       pm.max_children = 5
       pm.process_idle_timeout = 60
 
-      env[BDD_CONNECT] = "${configFile}"
-      php_admin_value[open_basedir] = "${configFile}:${varDir}:/tmp"
+      env[BDD_CONNECT] = "/run/keys/webapps/prod-naturaloutil"
+      php_admin_value[open_basedir] = "/run/keys/webapps/prod-naturaloutil:${varDir}:/tmp"
       '';
     services.myPhpfpm.poolPhpConfigs.jerome = ''
       extension=${pkgs.php}/lib/php/extensions/mysqli.so
index f6cb5bbe86d6f39d17a01ad3a7d6eb5f0ae90240..4e464ebfda106da940bfeaf1749795a8604728d5 100644 (file)
@@ -16,7 +16,12 @@ let
     '';
   };
   davical = rec {
-    config = writeText "davical_config.php" ''
+    keys."dav-davical" = {
+      destDir = "/run/keys/webapps";
+      user = apache.user;
+      group = apache.group;
+      permissions = "0700";
+      text = ''
         <?php
         $c->pg_connect[] = "dbname=${env.postgresql.database} user=${env.postgresql.user} host=${env.postgresql.socket} password=${env.postgresql.password}";
 
@@ -69,6 +74,7 @@ let
         $c->do_not_sync_from_ldap = array('admin' => true);
         include('drivers_ldap.php');
       '';
+    };
     webapp = stdenv.mkDerivation rec {
       version = "1.1.7";
       name = "davical-${version}";
@@ -84,7 +90,7 @@ let
       installPhase = ''
         mkdir -p $out
         cp -ra config dba docs htdocs inc locale po scripts testing zonedb $out
-        ln -s ${config} $out/config/config.php
+        ln -s /run/keys/webapps/dav-davical $out/config/config.php
       '';
       buildInputs = [ gettext ];
     };
@@ -131,7 +137,8 @@ let
         '';
     };
     phpFpm = rec {
-      basedir = builtins.concatStringsSep ":" [ webapp config awl ];
+      serviceDeps = [ "postgresql.service" "openldap.service" "dav-davical-key.service" ];
+      basedir = builtins.concatStringsSep ":" [ webapp "/run/keys/webapps/dav-davical" awl ];
       socket = "/var/run/phpfpm/davical.sock";
       pool = ''
         listen = ${socket}
index 5b5d21edba97b96e85127f436a4e20998362f1e9..56b3006edad0449079b6d92f0d5263a222852957 100644 (file)
@@ -14,6 +14,7 @@ in {
   config = lib.mkIf cfg.enable {
     security.acme.certs."eldiron".extraDomains."dav.immae.eu" = null;
 
+    deployment.keys = davical.keys;
     services.myWebsites.tools.modules = davical.apache.modules;
 
     services.myWebsites.tools.vhostConfs.dav = {