2024-07-13 15:44:07 +02:00
|
|
|
{ config, pkgs, lib, materusArg, ... }:
|
|
|
|
{
|
|
|
|
options.waffentragerService.auth.lldap.enable = materusArg.pkgs.lib.mkBoolOpt false "Enable lldap";
|
|
|
|
config =
|
|
|
|
let
|
|
|
|
cfg = config.waffentragerService.auth.lldap;
|
|
|
|
in
|
|
|
|
lib.mkIf cfg.enable {
|
|
|
|
waffentragerService.elements.enable = true;
|
2024-07-13 19:02:17 +02:00
|
|
|
waffentragerService.nginx.enable = true;
|
|
|
|
services.nginx.virtualHosts."mamba.podkos.pl" = {
|
|
|
|
forceSSL = true;
|
|
|
|
http3 = true;
|
|
|
|
sslTrustedCertificate = "/var/lib/mnt_acme/mamba.podkos.pl/chain.pem";
|
|
|
|
sslCertificateKey = "/var/lib/mnt_acme/mamba.podkos.pl/key.pem";
|
|
|
|
sslCertificate = "/var/lib/mnt_acme/mamba.podkos.pl/fullchain.pem";
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://127.0.0.1:17170";
|
|
|
|
extraConfig = ''
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-Ssl on;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
|
|
|
|
|
|
|
|
allow ${materusArg.ip-masks.wireguard.private};
|
|
|
|
allow 192.168.100.0/24;
|
|
|
|
deny all;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-13 15:44:07 +02:00
|
|
|
systemd.services.lldap = {
|
|
|
|
requires = [ "elements-mount.service" ];
|
|
|
|
after = [ "elements-mount.service" ];
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = lib.mkForce false;
|
|
|
|
WorkingDirectory = lib.mkForce config.waffentragerService.elements.lldapDir;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
users.groups.lldap = { };
|
|
|
|
users.users.lldap = {
|
|
|
|
group = "lldap";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
2024-07-22 15:31:57 +02:00
|
|
|
sops.secrets.jwt = { owner = "lldap"; group = "lldap"; mode = "0440"; };
|
2024-07-13 19:02:17 +02:00
|
|
|
sops.secrets."lldap-database" = { owner = "lldap"; group = "lldap"; };
|
2024-07-13 15:44:07 +02:00
|
|
|
services.lldap.enable = true;
|
2024-07-13 20:11:06 +02:00
|
|
|
services.lldap.environmentFile = config.sops.templates."lldap.env".path;
|
2024-07-13 19:02:17 +02:00
|
|
|
sops.templates."lldap.env" = {
|
|
|
|
content = ''
|
|
|
|
LLDAP_JWT_SECRET_FILE="${config.sops.secrets.jwt.path}"
|
|
|
|
LLDAP_DATABASE_URL="postgres://lldap:${config.sops.placeholder."lldap-database"}@%2Fvar%2Frun%2Fpostgresql/lldap"
|
|
|
|
'';
|
|
|
|
owner = "lldap";
|
|
|
|
group = "lldap";
|
2024-07-13 15:44:07 +02:00
|
|
|
};
|
2024-07-13 19:02:17 +02:00
|
|
|
|
2024-07-13 15:44:07 +02:00
|
|
|
services.lldap.settings = {
|
|
|
|
ldap_base_dn = "dc=podkos,dc=pl";
|
2024-07-22 15:31:57 +02:00
|
|
|
|
|
|
|
ldap_host = "127.0.0.1";
|
2024-07-13 19:02:17 +02:00
|
|
|
http_url = "https://mamba.podkos.pl";
|
2024-07-13 15:44:07 +02:00
|
|
|
ldap_user_dn = "master";
|
|
|
|
ldap_user_email = "materus@podkos.pl";
|
2024-08-08 20:45:42 +02:00
|
|
|
ldap_port = 3890;
|
2024-07-13 15:44:07 +02:00
|
|
|
key_seed = materusArg.waffentrager.lldap.seed;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|