2024-02-05 11:46:52 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2023-06-01 16:59:19 +02:00
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.eboskma.keycloak;
|
|
|
|
in
|
|
|
|
{
|
2024-02-05 11:46:52 +01:00
|
|
|
options.eboskma.keycloak = {
|
|
|
|
enable = mkEnableOption "keycloak";
|
|
|
|
};
|
2023-06-01 16:59:19 +02:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.keycloak = {
|
|
|
|
enable = true;
|
|
|
|
database.passwordFile = config.sops.secrets.keycloak-db-password.path;
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
hostname = "id.datarift.nl";
|
|
|
|
http-host = "127.0.0.1";
|
|
|
|
http-port = 8081;
|
2024-10-10 08:42:11 +02:00
|
|
|
http-enabled = true;
|
|
|
|
proxy-headers = "xforwarded";
|
2023-11-01 09:31:30 +01:00
|
|
|
features = "docker";
|
2023-06-01 16:59:19 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-02-05 11:46:52 +01:00
|
|
|
services.caddy = {
|
2023-06-01 16:59:19 +02:00
|
|
|
enable = true;
|
|
|
|
|
|
|
|
email = "erwin@datarift.nl";
|
|
|
|
|
|
|
|
virtualHosts = {
|
|
|
|
"${config.services.keycloak.settings.hostname}" = {
|
|
|
|
extraConfig = ''
|
2023-06-08 10:03:58 +02:00
|
|
|
@public_or_allowed_remote {
|
2023-10-23 08:09:38 +02:00
|
|
|
expression path('/realms/*', '/resources/*', '/js/*', '/robots.txt') || remote_ip('86.85.243.40/32', '2a02:a441:c959:1::/64', '100.64.0.0/10', 'fd7a:115c:a1e0:ab12:4843:cd96:6240:0000/106')
|
2023-06-08 10:03:58 +02:00
|
|
|
}
|
|
|
|
|
2023-07-04 20:29:59 +02:00
|
|
|
route {
|
2024-11-16 22:11:03 +01:00
|
|
|
reverse_proxy @public_or_allowed_remote ${config.services.keycloak.settings.http-host}:${toString config.services.keycloak.settings.http-port}
|
2023-07-04 20:29:59 +02:00
|
|
|
|
2024-11-16 22:11:03 +01:00
|
|
|
respond 403 {
|
|
|
|
body "Nope."
|
|
|
|
close
|
|
|
|
}
|
2023-07-04 20:29:59 +02:00
|
|
|
}
|
2023-06-01 16:59:19 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
security.acme.acceptTerms = true;
|
|
|
|
|
2024-02-05 11:46:52 +01:00
|
|
|
networking.firewall.allowedTCPPorts = [
|
|
|
|
80
|
|
|
|
443
|
|
|
|
];
|
2023-06-01 16:59:19 +02:00
|
|
|
};
|
|
|
|
}
|