From 9577477460d6b392ebfbf5bf6afeb64859740798 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 8 Apr 2024 23:07:41 +0200 Subject: [PATCH] bekkalokk/nettsiden: add secrets --- hosts/bekkalokk/services/website/default.nix | 43 ++++++++++++-------- secrets/bekkalokk/bekkalokk.yaml | 12 ++++-- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/hosts/bekkalokk/services/website/default.nix b/hosts/bekkalokk/services/website/default.nix index 7f07faeb..60760000 100644 --- a/hosts/bekkalokk/services/website/default.nix +++ b/hosts/bekkalokk/services/website/default.nix @@ -7,7 +7,18 @@ in { ./fetch-gallery.nix ]; - services.idp.sp-remote-metadata = [ "https://www2.pvv.ntnu.no/simplesaml/" ]; + sops.secrets = lib.genAttrs [ + "nettsiden/door_secret" + "nettsiden/mysql_password" + "nettsiden/simplesamlphp/admin_password" + "nettsiden/simplesamlphp/cookie_salt" + ] (_: { + owner = config.services.phpfpm.pools.pvv-nettsiden.user; + group = config.services.phpfpm.pools.pvv-nettsiden.group; + restartUnits = [ "phpfpm-pvv-nettsiden.service" ]; + }); + + services.idp.sp-remote-metadata = [ "https://${cfg.domainName}/simplesaml/" ]; services.pvv-nettsiden = { enable = true; @@ -18,12 +29,12 @@ in { "${pkgs.pvv-nettsiden.passthru.simplesamlphpPath}/config/authsources.php" = pkgs.writeText "pvv-nettsiden-authsources.php" '' array( - # 'core:AdminPassword' - # ), + 'admin' => array( + 'core:AdminPassword' + ), 'default-sp' => array( 'saml:SP', - 'entityID' => 'https://www2.pvv.ntnu.no/simplesaml/', + 'entityID' => 'https://${cfg.domainName}/simplesaml/', 'idp' => 'https://idp2.pvv.ntnu.no/', ), ); @@ -33,21 +44,24 @@ in { domainName = "www2.pvv.ntnu.no"; - settings = { - DOOR_SECRET = "verysecret"; + settings = let + includeFromSops = path: format.lib.mkRaw "file_get_contents('${config.sops.secrets."nettsiden/${path}".path}')"; + in { + DOOR_SECRET = includeFromSops "door_secret"; DB = { - DSN = "mysql:dbname=www_data_www2;host=mysql.pvv.ntnu.no"; - USER = "www-data_www2"; - PASS = format.lib.mkRaw "file_get_contents('${config.sops.secrets."nettsiden/database/password".path}')"; + DSN = "mysql:dbname=www-data_nettside;host=mysql.pvv.ntnu.no"; + USER = "www-data_nettsi"; + PASS = includeFromSops "mysql_password"; }; + # TODO: set up postgres session for simplesamlphp SAML = { - COOKIE_SALT = "changeme"; + COOKIE_SALT = includeFromSops "simplesamlphp/cookie_salt"; COOKIE_SECURE = true; ADMIN_NAME = "PVV Drift"; ADMIN_EMAIL = "drift@pvv.ntnu.no"; - ADMIN_PASSWORD = "torskefjes"; + ADMIN_PASSWORD = includeFromSops "simplesamlphp/admin_password"; TRUSTED_DOMAINS = [ cfg.domainName ]; }; }; @@ -58,9 +72,4 @@ in { "php_admin_flag[log_errors]" = true; "catch_workers_output" = true; }; - - sops.secrets."nettsiden/database/password" = { - owner = config.services.phpfpm.pools.pvv-nettsiden.user; - group = config.services.phpfpm.pools.pvv-nettsiden.group; - }; } diff --git a/secrets/bekkalokk/bekkalokk.yaml b/secrets/bekkalokk/bekkalokk.yaml index 11ac61a6..9ba21008 100644 --- a/secrets/bekkalokk/bekkalokk.yaml +++ b/secrets/bekkalokk/bekkalokk.yaml @@ -23,8 +23,12 @@ idp: postgres_password: ENC[AES256_GCM,data:HGwKLbn/umPLPgH+qpXtugvXzOcXdlhK,iv:ypTW0VLSape8K5aCYu3BdjG/oMmqvfDSLw9uGLthb0Q=,tag:qlDMGz59qzMwEwBYxsC0XQ==,type:str] privatekey: ENC[AES256_GCM,data:pK74wjuk9lt2PNJIzi6NpPBkxcSRsBZJl28BElUiri2zz17CY81x66CMlFsNjvzKB3JVX+b28FHFuSsEpd/mAPtmzZPR+CoWBHvU+OrSYYoufBxexRTtXzu0vx/KFL4X5tsb+GCgfm72CM+u9dElYHJzn3teBUmZc0pIoF29slTuwF+iZrbFwaieECxXMjHC9f+ivxWQsOvYFjhmAwgjBw/LsfURgLxZwcIRiiK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NKwDU=,tag:7x9AxafBNcJIcRetZNHOIg==,type:str] + mysql_password: ENC[AES256_GCM,data:Uv74HhWtYRbaFHcfh0Rk/Q==,iv:/lRTaMepwpJKZJWHnwb98Ywa1zP4e2EqYGmwI7BCl1I=,tag:ZnE0u2/65zdkONcoiBGSOQ==,type:str] + door_secret: ENC[AES256_GCM,data:t0jEN1WnyEi10KRSg4Dlcd7IuIMBiOU7riOdYSZjvZTQqPijRYIoMEQ6OemIkD1Yg67uISTxnjxP,iv:Ss02VGKRa4oZMubbi8IfQDAjh3h295+n07vOx/IZGBs=,tag:OvdxqIUdYi/cR7IjopSVQQ==,type:str] + simplesamlphp: + postgres_password: ENC[AES256_GCM,data:SvbrdHF4vQ94DgoEfy67QS5oziAsMT8H,iv:LOHBqMecA6mgV3NMfmfTh3zDGiDve+t3+uaO53dIxt4=,tag:9ffz84ozIqytNdGB1COMhA==,type:str] + cookie_salt: ENC[AES256_GCM,data:VmODSLOP1YDBrpHdk/49qx9BS+aveEYDQ1D24d4zCi06kZsCENCr+vdPAnTeM1pw98RTr3yZAEQTh4s90b6v8Q==,iv:vRClu6neyYPFdtD63kjnvK2iNOIHMbh+9qEGph7CI60=,tag:66fgppVxY0egs4+9XfDBPA==,type:str] + admin_password: ENC[AES256_GCM,data:SADr/zN3F0tW339kSK1nD9Pb38rw7hz8,iv:s5jgl1djXd5JKwx1WG/w2Q4STMMpjJP91qxOwAoNcL0=,tag:N8bKnO9N0ei06HDkSGt6XQ==,type:str] sops: kms: [] gcp_kms: [] @@ -58,8 +62,8 @@ sops: akVjeTNTeGorZjJQOVlMeCtPRUVYL3MK+VMvGxrbzGz4Q3sdaDDWjal+OiK+JYKX GHiMXVHQJZu/RrlxMjHKN6V3iaqxZpuvLAEJ2Lzy5EOHPtuiiRyeHQ== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-04-02T19:09:44Z" - mac: ENC[AES256_GCM,data:9H6xPlE5+ddkezGQHj5IFjXv8LjJjGP8qf2wK44rMdmOQdsLzs4HryQmE+FctohtBfqbxCNdWsmQajPK5YwKbyEF+IMo40Ga8G3ORxYPn5dOSFx6lA/xZRJlqEsHr8WutlGmyJgqst+PZFBClDtOWqsI83HbQJ5wDxYkldEbVC0=,iv:jRfn8lufDbRTUHVe0tZiriia+KAa3Y23FSWXiZNuXRY=,tag:C7pg0BoR/nej0B5iTu3l0w==,type:str] + lastmodified: "2024-04-08T20:36:13Z" + mac: ENC[AES256_GCM,data:IObBR2H3cPIvBNWSo7A5xwyKeg2HbFkfxcU1U5BpRx2gvNb9/h7lextQ6IWPHOS/LZRXY+lZdhX6zLf6aLQjxTATZcrcF2BIu6YM5wppXOjVxhy3dkItU5TGPuxBdZEZ1bEpFu3B1Ooc1UdWvEWqZz2Mcn2akoX53Mj2vU8WGO8=,iv:fHvPHO33y6y3OSbVkojw2+XnpCNHO1AnCm2RnuwxPVA=,tag:m44YZd4Q4DEHCoDCoayqsg==,type:str] pgp: - created_at: "2023-05-21T00:28:40Z" enc: |