Skip to content

Commit

Permalink
mCaptcha: update setting of db user password
Browse files Browse the repository at this point in the history
Co-authored-by: Ali Jamadi <[email protected]>
Co-authored-by: Adrien Faure <[email protected]>
Co-authored-by: Shahar "Dawn" Or <[email protected]>
  • Loading branch information
4 people committed Jun 6, 2024
1 parent 98203d7 commit 490b42a
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions projects/mCaptcha/tests/bring-your-own-services.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{sources, ...}: let
{
sources,
lib,
...
}: let
inherit
(lib)
mkAfter
;

port = 7000;
urlRoot = "http://localhost:${builtins.toString port}";
redisPassword = "(*&(*):ps@r}";
Expand All @@ -22,7 +31,7 @@ in {
services.mcaptcha.captcha.saltFile = pkgs.writeText "salt" "asdl;kjfhjawehfpa;osdkjasdvjaksndfpoanjdfainsdfaijdsfajlkjdsaf;ajsdfweroire";

services.mcaptcha.settings.database.name = "my_mcaptcha";
services.mcaptcha.settings.database.username = "role_mcaptcha";
services.mcaptcha.settings.database.username = "my_mcaptcha";
services.mcaptcha.settings.database.hostname = "my_own_services";
services.mcaptcha.settings.database.port = 5432;
services.mcaptcha.database.passwordFile = pkgs.writeText "db-password" "mcaptcha-db-secret";
Expand All @@ -38,10 +47,16 @@ in {
networking.firewall.enable = false;
services.postgresql.enable = true;
services.postgresql.enableTCPIP = true;
services.postgresql.initialScript = pkgs.writeText "postgresql-init-script" ''
CREATE ROLE role_mcaptcha WITH LOGIN PASSWORD 'mcaptcha-db-secret';
CREATE DATABASE my_mcaptcha;
GRANT ALL PRIVILEGES ON DATABASE my_mcaptcha TO role_mcaptcha;
services.postgresql.ensureDatabases = ["my_mcaptcha"];
services.postgresql.ensureUsers = [
{
name = "my_mcaptcha";
ensureDBOwnership = true;
}
];

systemd.services.postgresql.postStart = mkAfter ''
$PSQL my_mcaptcha -c "ALTER USER my_mcaptcha WITH PASSWORD 'mcaptcha-db-secret'"
'';
services.postgresql.authentication = ''
#type database DBuser auth-method
Expand Down

0 comments on commit 490b42a

Please sign in to comment.