]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Move Ludivine Piedsjaloux and Florian's websites passwords to a secure location
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 15 Apr 2019 22:35:59 +0000 (00:35 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 15 Apr 2019 22:35:59 +0000 (00:35 +0200)
Related issue: https://git.immae.eu/mantisbt/view.php?id=122

nixops/modules/websites/ludivine/default.nix
nixops/modules/websites/ludivine/ludivinecassal.nix
nixops/modules/websites/piedsjaloux/default.nix
nixops/modules/websites/piedsjaloux/piedsjaloux.nix
nixops/modules/websites/tellesflorian/default.nix
nixops/modules/websites/tellesflorian/tellesflorian.nix

index 3dd0ee73f17b31201b5e6c72922e46dfc291b109..220f5c2b43657a4c6b36d900c83d4e06d85ee385 100644 (file)
@@ -21,6 +21,7 @@ in {
 
   config = lib.mkMerge [
     (lib.mkIf cfg.production.enable {
+      deployment.keys = ludivinecassal_prod.keys;
       services.myWebsites.commons.stats.enable = true;
       services.myWebsites.commons.stats.sites = [
         {
@@ -51,6 +52,7 @@ in {
       };
     })
     (lib.mkIf cfg.integration.enable {
+      deployment.keys = ludivinecassal_dev.keys;
       security.acme.certs."eldiron".extraDomains."ludivine.immae.eu" = null;
 
       services.myPhpfpm.poolConfigs.ludivinecassal_dev = ludivinecassal_dev.phpFpm.pool;
index 114c4ac2509d0eb7679ab3b07f7e2f4051dd5154..244b05ea113911d114881ca11509ff6d075de322 100644 (file)
@@ -3,8 +3,12 @@ let
   ludivinecassal = { config }: rec {
     environment = config.environment;
     varDir = "/var/lib/ludivinecassal_${environment}";
-    configRoot =
-      writeText "parameters.yml" ''
+    keys."${environment}-ludivinecassal" = {
+      destDir = "/run/keys/webapps";
+      user = apache.user;
+      group = apache.group;
+      permissions = "0700";
+      text = ''
         # This file is auto-generated during the composer install
         parameters:
             database_host: ${config.mysql.host}
@@ -34,6 +38,7 @@ let
             sass: ${sass}/bin/sass
             ruby: ${ruby}/bin/ruby
       '';
+    };
     phpFpm = rec {
       socket = "/var/run/phpfpm/ludivinecassal-${environment}.sock";
       pool = ''
@@ -45,7 +50,7 @@ let
         php_admin_value[upload_max_filesize] = 20M
         php_admin_value[post_max_size] = 20M
         ;php_admin_flag[log_errors] = on
-        php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp"
+        php_admin_value[open_basedir] = "/run/keys/webapps/${environment}-ludivinecassal:${webappDir}:${varDir}:/tmp"
         php_admin_value[session.save_path] = "${varDir}/phpSessions"
         ${if environment == "dev" then ''
         pm = ondemand
@@ -151,7 +156,14 @@ let
         noDev = (environment == "prod");
         preInstall = ''
           export SYMFONY_ENV="${environment}"
-          ln -sf ${configRoot} app/config/parameters.yml
+          cp app/config/parameters.yml.dist app/config/parameters.yml
+          cat >> app/config/parameters.yml <<EOF
+          leapt_im:
+              binary_path: ${imagemagick}/bin
+          assetic:
+              sass: ${sass}/bin/sass
+              ruby: ${ruby}/bin/ruby
+          EOF
           sed -i -e "/Incenteev..ParameterHandler..ScriptHandler::buildParameters/d" composer.json
           '';
         # /!\ miniatures and data need to be in the same physical dir due to a
@@ -159,6 +171,7 @@ let
         postInstall = ''
           rm -rf var/{logs,cache,data,miniatures,tmp}
           ln -sf ${varDir}/{logs,cache,data,miniatures,tmp} var/
+          ln -sf /run/keys/webapps/${environment}-ludivinecassal app/config/parameters.yml
           '';
         buildInputs = [ sass ];
       });
index 54e063db07e7b680d9bb5addc50b8fb8e7ffccbc..1c6864c861ded6deb3b95133376bbfe7069ec05f 100644 (file)
@@ -25,6 +25,7 @@ in {
 
   config = lib.mkMerge [
     (lib.mkIf cfg.production.enable {
+      deployment.keys = piedsjaloux_prod.keys;
       services.myWebsites.commons.stats.enable = true;
       services.myWebsites.commons.stats.sites = [
         {
@@ -55,6 +56,7 @@ in {
       };
     })
     (lib.mkIf cfg.integration.enable {
+      deployment.keys = piedsjaloux_dev.keys;
       security.acme.certs."eldiron".extraDomains."piedsjaloux.immae.eu" = null;
       services.myPhpfpm.poolConfigs.piedsjaloux_dev = piedsjaloux_dev.phpFpm.pool;
       system.activationScripts.piedsjaloux_dev = piedsjaloux_dev.activationScript;
index bb1726208fd67d65ba8c939d953ec834b9c29a99..688b9fdd82368154672a7d7c4389fd678772c89b 100644 (file)
@@ -3,8 +3,12 @@ let
   piedsjaloux = { config }: rec {
     environment = config.environment;
     varDir = "/var/lib/piedsjaloux_${environment}";
-    configRoot =
-      writeText "parameters.yml" ''
+    keys."${environment}-piedsjaloux" = {
+      destDir = "/run/keys/webapps";
+      user = apache.user;
+      group = apache.group;
+      permissions = "0700";
+      text = ''
         # This file is auto-generated during the composer install
         parameters:
             database_host: ${config.mysql.host}
@@ -22,6 +26,7 @@ let
         leapt_im:
             binary_path: ${imagemagick}/bin
       '';
+    };
     phpFpm = rec {
       socket = "/var/run/phpfpm/piedsjaloux-${environment}.sock";
       pool = ''
@@ -33,7 +38,7 @@ let
         php_admin_value[upload_max_filesize] = 20M
         php_admin_value[post_max_size] = 20M
         ;php_admin_flag[log_errors] = on
-        php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp"
+        php_admin_value[open_basedir] = "/run/keys/webapps/${environment}-piedsjaloux:${webappDir}:${varDir}:/tmp"
         php_admin_value[session.save_path] = "${varDir}/phpSessions"
         env[PATH] = ${lib.makeBinPath [ pkgs.apg pkgs.unzip ]}
         ${if environment == "dev" then ''
@@ -146,7 +151,7 @@ let
         postInstall = ''
           cd $out
           rm app/config/parameters.yml
-          ln -sf ${configRoot} app/config/parameters.yml
+          ln -sf /run/keys/webapps/${environment}-piedsjaloux app/config/parameters.yml
           rm -rf var/{logs,cache,data,miniatures,tmp}
           ln -sf ${varDir}/{logs,cache,data,miniatures,tmp} var/
           '';
index 389c4916c5e857271cfee5d753fad71c7ae93d40..97931b9d94f49838456df0eab7177c3d36ceb8fe 100644 (file)
@@ -16,6 +16,7 @@ in {
   };
 
   config = lib.mkIf cfg.integration.enable {
+    deployment.keys = tellesflorian_dev.keys;
     security.acme.certs."eldiron".extraDomains."app.tellesflorian.com" = null;
     services.myPhpfpm.poolConfigs.tellesflorian_dev = tellesflorian_dev.phpFpm.pool;
     system.activationScripts.tellesflorian_dev = tellesflorian_dev.activationScript;
index e42158199b003008bae19b774ef445add7c0e8cd..4c76a76b6af245cfa8057d6f72a6c6831194d4aa 100644 (file)
@@ -3,8 +3,12 @@ let
   tellesflorian = { config }: rec {
     environment = config.environment;
     varDir = "/var/lib/tellesflorian_${environment}";
-    configRoot =
-      writeText "parameters.yml" ''
+    keys."${environment}-tellesflorian" = {
+      destDir = "/run/keys/webapps";
+      user = apache.user;
+      group = apache.group;
+      permissions = "0700";
+      text = ''
         # This file is auto-generated during the composer install
         parameters:
             database_host: ${config.mysql.host}
@@ -18,6 +22,7 @@ let
             mailer_password: null
             secret: ${config.secret}
       '';
+    };
     phpFpm = rec {
       socket = "/var/run/phpfpm/floriantelles-${environment}.sock";
       pool = ''
@@ -29,7 +34,7 @@ let
         php_admin_value[upload_max_filesize] = 20M
         php_admin_value[post_max_size] = 20M
         ;php_admin_flag[log_errors] = on
-        php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp"
+        php_admin_value[open_basedir] = "/run/keys/webapps/${environment}-tellesflorian:${webappDir}:${varDir}:/tmp"
         php_admin_value[session.save_path] = "${varDir}/phpSessions"
         ${if environment == "dev" then ''
         pm = ondemand
@@ -44,9 +49,15 @@ let
         pm.max_spare_servers = 3
         ''}'';
     };
-    passwords = writeText "tellesflorian_passwords" ''
-      invite:${config.invite_passwords}
+    keys."${environment}-tellesflorian-passwords" = {
+      destDir = "/run/keys/webapps";
+      user = apache.user;
+      group = apache.group;
+      permissions = "0700";
+      text = ''
+        invite:${config.invite_passwords}
       '';
+    };
     apache = rec {
       user = "wwwrun";
       group = "wwwrun";
@@ -64,7 +75,7 @@ let
         Use LDAPConnect
         Require ldap-group   cn=app.tellesflorian.com,cn=httpd,ou=services,dc=immae,dc=eu
 
-        AuthUserFile "${passwords}"
+        AuthUserFile "/run/keys/webapps/${environment}-tellesflorian-passwords"
         Require user "invite"
 
         ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://tellesflorian.com\"></html>"
@@ -145,7 +156,7 @@ let
         postInstall = ''
           cd $out
           rm app/config/parameters.yml
-          ln -sf ${configRoot} app/config/parameters.yml
+          ln -sf /run/keys/webapps/${environment}-tellesflorian app/config/parameters.yml
           rm -rf var/{logs,cache}
           ln -sf ${varDir}/var/{logs,cache,sessions} var/
           '';