depot/hosts/VEGAS/services/sso/default.nix

43 lines
1.1 KiB
Nix
Raw Normal View History

2021-10-16 21:24:30 +03:00
{ config, lib, pkgs, tools, ... }:
with tools.nginx;
let
login = "login.${tools.meta.domain}";
cfg = config.services.keycloak;
in
{
2022-05-31 12:48:07 +03:00
tested.requiredChecks = [ "keycloak" ];
2021-11-29 02:38:59 +02:00
reservePortsFor = [ "keycloak" ];
2021-10-16 21:24:30 +03:00
imports = [
./identity-management.nix
];
age.secrets.keycloak-dbpass = {
file = ../../../../secrets/keycloak-dbpass.age;
owner = "root";
group = "root";
mode = "0400";
};
services.nginx.virtualHosts = {
2022-05-30 23:00:21 +03:00
"${login}" = lib.recursiveUpdate (vhosts.proxy "http://${cfg.settings.http-host}:${config.portsStr.keycloak}") {
2021-10-16 21:24:30 +03:00
locations."= /".return = "302 /auth/realms/master/account/";
};
"account.${domain}" = vhosts.redirect "https://${login}/auth/realms/master/account/";
};
services.keycloak = {
enable = true;
database = {
createLocally = true;
type = "postgresql";
passwordFile = config.age.secrets.keycloak-dbpass.path;
};
2022-05-30 23:00:21 +03:00
settings = {
http-host = "127.0.0.1";
http-port = config.ports.keycloak;
hostname = login;
proxy = "edge";
# for backcompat, TODO: remove
http-relative-path = "/auth";
2021-10-16 21:24:30 +03:00
};
};
}