1
0
Fork 0
pvv-nixos-config/hosts/shark/services/kanidm.nix

48 lines
1.2 KiB
Nix
Raw Normal View History

2023-09-16 22:21:47 +02:00
{ config, pkgs, lib, ... }:
let
cfg = config.services.kanidm;
2023-09-17 03:28:31 +02:00
domain = "idmtest.pvv.ntnu.no";
2023-09-16 22:21:47 +02:00
bindaddr_web = "127.0.0.1:8300"; #
bindaddr_ldaps = "0.0.0.0:636";
in {
# Kanidm - Identity management / auth provider
services.kanidm = {
enableServer = true;
serverSettings = let
credsDir = "/run/credentials/kanidm.service";
in {
inherit domain;
ldapbindaddress = bindaddr_ldaps;
bindaddress = bindaddr_web;
origin = "https://${domain}";
tls_chain = "${credsDir}/fullchain.pem";
tls_key = "${credsDir}/key.pem";
};
};
2023-09-17 03:28:31 +02:00
systemd.services.kanidm = {
requires = [ "acme-finished-${domain}.target" ];
2023-09-16 22:21:47 +02:00
serviceConfig.LoadCredential = let
2023-09-17 03:28:31 +02:00
certDir = config.security.acme.certs.${domain}.directory;
2023-09-16 22:21:47 +02:00
in [
"fullchain.pem:${certDir}/fullchain.pem"
"key.pem:${certDir}/key.pem"
];
};
services.nginx.virtualHosts."${cfg.serverSettings.domain}" = {
forceSSL = true;
enableACME = true;
locations."/".proxyPass = "https://${cfg.serverSettings.bindaddress}";
};
environment = {
systemPackages = [ pkgs.kanidm ]; # CLI tool
etc."kanidm/config".text = ''
uri="${cfg.serverSettings.origin}"
'';
};
}