]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Move Aten and Connexionswing secrets to secure location
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 15 Apr 2019 22:04:34 +0000 (00:04 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 15 Apr 2019 22:04:34 +0000 (00:04 +0200)
Related issue: https://git.immae.eu/mantisbt/view.php?id=122

nixops/modules/websites/aten/aten.nix
nixops/modules/websites/aten/default.nix
nixops/modules/websites/connexionswing/connexionswing.nix
nixops/modules/websites/connexionswing/default.nix

index d9286c3fa7bd402ccfadd2f6e0d3d9100cfaf5c1..897b3ba4146d385b3d4de4987f0a1cb483c937af 100644 (file)
@@ -29,6 +29,17 @@ let
         pm.max_spare_servers = 3
         ''}'';
     };
+    keys."${environment}-aten" = {
+      destDir = "/run/keys/webapps";
+      user = apache.user;
+      group = apache.group;
+      permissions = "0700";
+      text = ''
+        SetEnv APP_ENV      "${environment}"
+        SetEnv APP_SECRET   "${config.secret}"
+        SetEnv DATABASE_URL "${config.psql_url}"
+        '';
+    };
     apache = rec {
       user = "wwwrun";
       group = "wwwrun";
@@ -40,9 +51,7 @@ let
         SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
       </FilesMatch>
 
-      SetEnv APP_ENV      "${environment}"
-      SetEnv APP_SECRET   "${config.secret}"
-      SetEnv DATABASE_URL "${config.psql_url}"
+      Include /run/keys/webapps/${environment}-aten
 
       ${if environment == "dev" then ''
       <Location />
@@ -124,8 +133,6 @@ let
         preInstall = ''
           export SYMFONY_ENV="${environment}"
           export APP_ENV="${environment}"
-          export DATABASE_URL="${config.psql_url}"
-          export APP_SECRET="${config.secret}"
           '';
         postInstall = ''
           ln -sf ${yarnModules}/node_modules .
index 51a36fbdb25e3b72130d4800e8ef63939388fcb0..776a02e7e2c5caa1e26df5455af516c0ba0522b5 100644 (file)
@@ -25,6 +25,7 @@ in {
 
   config = lib.mkMerge [
     (lib.mkIf cfg.production.enable {
+      deployment.keys = aten_prod.keys;
       services.myWebsites.commons.stats.enable = true;
       services.myWebsites.commons.stats.sites = [
         {
@@ -56,6 +57,7 @@ in {
       };
     })
     (lib.mkIf cfg.integration.enable {
+      deployment.keys = aten_dev.keys;
       security.acme.certs."eldiron".extraDomains."dev.aten.pro" = null;
       services.myPhpfpm.poolConfigs.aten_dev = aten_dev.phpFpm.pool;
       system.activationScripts.aten_dev = aten_dev.activationScript;
index 8fbca2d8d6d703a8a1ad05be3966bf02b62a7dd4..c1781841db51d16dadd1041e909953fbbf1bb6cc 100644 (file)
@@ -3,8 +3,12 @@ let
   connexionswing = { config }: rec {
     environment = config.environment;
     varDir = "/var/lib/connexionswing_${environment}";
-    configRoot =
-      writeText "parameters.yml" ''
+    keys."${environment}-connexionswing" = {
+      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}
@@ -27,6 +31,7 @@ let
               arguments: ['/run/wrappers/bin/sendmail -bs']
         '' else ""}
       '';
+    };
     phpFpm = rec {
       socket = "/var/run/phpfpm/connexionswing-${environment}.sock";
       phpConfig = ''
@@ -41,7 +46,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] = "/run/wrappers/bin/sendmail:${configRoot}:${webappDir}:${varDir}:/tmp"
+        php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:/run/keys/webapps/${environment}-connexionswing:${webappDir}:${varDir}:/tmp"
         php_admin_value[session.save_path] = "${varDir}/phpSessions"
         ${if environment == "dev" then ''
         pm = ondemand
@@ -166,7 +171,7 @@ let
           cd $out
           ${if environment == "prod" then "php ./bin/console assetic:dump --env=prod --no-debug" else ""}
           rm app/config/parameters.yml
-          ln -sf ${configRoot} app/config/parameters.yml
+          ln -sf /run/keys/webapps/${environment}-connexionswing app/config/parameters.yml
           rm -rf var/{logs,cache}
           ln -sf ${varDir}/var/{logs,cache} var/
           ln -sf ${varDir}/{medias,uploads} web/images/
index f98b3491397e15cb4bb04a8b780d718342e08b9a..752382f855e9d2c20ca15487de7518dd4e187f41 100644 (file)
@@ -25,6 +25,7 @@ in {
 
   config = lib.mkMerge [
     (lib.mkIf cfg.production.enable {
+      deployment.keys = connexionswing_prod.keys;
       services.myWebsites.commons.stats.enable = true;
       services.myWebsites.commons.stats.sites = [
         {
@@ -58,6 +59,7 @@ in {
       };
     })
     (lib.mkIf cfg.integration.enable {
+      deployment.keys = connexionswing_dev.keys;
       security.acme.certs."eldiron".extraDomains."sandetludo.immae.eu" = null;
       security.acme.certs."eldiron".extraDomains."connexionswing.immae.eu" = null;
       services.myPhpfpm.poolConfigs.connexionswing_dev = connexionswing_dev.phpFpm.pool;