nixos: rotate Forgejo's internal token and JWT secrets, Grafana's key
Some checks failed
nixos / nixos (push) Failing after 57s
Some checks failed
nixos / nixos (push) Failing after 57s
Forgejo's INTERNAL_TOKEN, JWT_SECRET and LFS_JWT_SECRET sat in the old repository history for a year; Grafana ran on its public default secret_key. New values, generated by Forgejo and openssl, straight into sops. SECRET_KEY stays: changing it would break 2FA. sops-nix does not restart anything when a secret changes. The secrets now name the unit that reads them (Forgejo, Grafana, postgres-roles, garage-bootstrap), so a changed value takes effect on the deploy. Assisted-by: Claude:opus-5-5
This commit is contained in:
parent
c6431760bd
commit
f1baa4025c
4 changed files with 63 additions and 52 deletions
|
|
@ -22,7 +22,10 @@ in
|
|||
"smtp_user"
|
||||
"smtp_password"
|
||||
"metrics_token"
|
||||
]) (_: { owner = cfg.user; });
|
||||
]) (_: {
|
||||
owner = cfg.user;
|
||||
restartUnits = [ "forgejo.service" ]; # a changed secret takes effect
|
||||
});
|
||||
|
||||
users.users.git = {
|
||||
isSystemUser = true;
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ in
|
|||
}
|
||||
// lib.listToAttrs (
|
||||
lib.concatMap (k: [
|
||||
(lib.nameValuePair "garage/${k}_access_key" { })
|
||||
(lib.nameValuePair "garage/${k}_secret_key" { })
|
||||
# A changed key is imported by restarting garage-bootstrap
|
||||
(lib.nameValuePair "garage/${k}_access_key" { restartUnits = [ "garage-bootstrap.service" ]; })
|
||||
(lib.nameValuePair "garage/${k}_secret_key" { restartUnits = [ "garage-bootstrap.service" ]; })
|
||||
]) keys
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,10 @@ let
|
|||
in
|
||||
{
|
||||
sops.secrets = {
|
||||
"monitoring/grafana_admin_password".owner = "grafana";
|
||||
"monitoring/grafana_admin_password" = {
|
||||
owner = "grafana";
|
||||
restartUnits = [ "grafana.service" ];
|
||||
};
|
||||
"monitoring/hcloud_ro_token".owner = "prometheus";
|
||||
"forgejo/metrics_token".owner = lib.mkForce "prometheus"; # Forgejo reads it as root, at start
|
||||
"alert/smtp_user".owner = lib.mkForce "grafana";
|
||||
|
|
@ -447,7 +450,10 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
sops.secrets."monitoring/grafana_secret_key".owner = "grafana";
|
||||
sops.secrets."monitoring/grafana_secret_key" = {
|
||||
owner = "grafana";
|
||||
restartUnits = [ "grafana.service" ];
|
||||
};
|
||||
|
||||
asxpio.routes.grafana = {
|
||||
hosts = [ "gf.asxp.io" ];
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@ let
|
|||
pg = config.services.postgresql.package;
|
||||
in
|
||||
{
|
||||
sops.secrets."postgres/asxpio_password" = { };
|
||||
sops.secrets."postgres/bingo_password" = { };
|
||||
# A changed password is set by restarting postgres-roles
|
||||
sops.secrets."postgres/asxpio_password".restartUnits = [ "postgres-roles.service" ];
|
||||
sops.secrets."postgres/bingo_password".restartUnits = [ "postgres-roles.service" ];
|
||||
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue