2023-10-28 13:05:30 +00:00
|
|
|
{
|
|
|
|
flake,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
age.secrets.keycloak-database-password = {
|
|
|
|
file = "${flake.self}/secrets/keycloak-database-password.age";
|
|
|
|
mode = "700";
|
|
|
|
#owner = "keycloak";
|
|
|
|
};
|
|
|
|
|
2023-10-28 19:34:45 +00:00
|
|
|
services.nginx.virtualHosts."auth.pub.solar" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
|
|
|
|
locations = {
|
|
|
|
"= /" = {
|
|
|
|
extraConfig = ''
|
|
|
|
return 302 /realms/pub.solar/account;
|
|
|
|
'';
|
|
|
|
};
|
2023-10-28 19:28:01 +00:00
|
|
|
|
2023-10-28 19:34:45 +00:00
|
|
|
"/" = {
|
|
|
|
extraConfig = ''
|
2023-10-29 11:30:36 +00:00
|
|
|
proxy_pass http://127.0.0.1:8080;
|
2023-11-03 12:07:53 +00:00
|
|
|
proxy_buffer_size 8k;
|
2023-10-28 19:34:45 +00:00
|
|
|
'';
|
|
|
|
};
|
2023-10-28 19:28:01 +00:00
|
|
|
};
|
2023-10-28 13:05:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# keycloak
|
|
|
|
services.keycloak = {
|
|
|
|
enable = true;
|
|
|
|
database.passwordFile = config.age.secrets.keycloak-database-password.path;
|
|
|
|
settings = {
|
|
|
|
hostname = "auth.pub.solar";
|
|
|
|
http-host = "127.0.0.1";
|
|
|
|
http-port = 8080;
|
|
|
|
proxy = "edge";
|
|
|
|
features = "declarative-user-profile";
|
|
|
|
};
|
|
|
|
themes = {
|
2023-10-28 21:18:44 +00:00
|
|
|
"pub.solar" = flake.inputs.keycloak-theme-pub-solar.legacyPackages.${pkgs.system}.keycloak-theme-pub-solar;
|
2023-10-28 13:05:30 +00:00
|
|
|
};
|
|
|
|
};
|
2023-11-05 21:54:09 +00:00
|
|
|
|
2023-11-05 22:47:06 +00:00
|
|
|
services.restic.backups.keycloak = {
|
2023-11-05 21:54:09 +00:00
|
|
|
paths = [
|
|
|
|
"/tmp/keycloak-backup.sql"
|
|
|
|
];
|
2023-11-05 22:47:06 +00:00
|
|
|
timerConfig = {
|
|
|
|
OnCalendar = "*-*-* 02:00:00 Etc/UTC";
|
|
|
|
# droppie will be offline if nachtigall misses the timer
|
|
|
|
Persistent = false;
|
|
|
|
};
|
|
|
|
initialize = true;
|
|
|
|
passwordFile = config.age.secrets."restic-repo-droppie".path;
|
|
|
|
repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar";
|
2023-11-05 21:54:09 +00:00
|
|
|
backupPrepareCommand = ''
|
|
|
|
${pkgs.sudo}/bin/sudo -iu postgres ${pkgs.postgresql}/bin/pg_dump -d keycloak > /tmp/keycloak-backup.sql
|
|
|
|
'';
|
|
|
|
backupCleanupCommand = ''
|
|
|
|
rm /tmp/keycloak-backup.sql
|
|
|
|
'';
|
|
|
|
};
|
2023-10-28 13:05:30 +00:00
|
|
|
}
|