2023-07-21 20:56:19 +00:00
|
|
|
{ config, pkgs, lib, inputs, ... }:
|
2023-06-18 21:49:31 +00:00
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.ldap_backend;
|
|
|
|
port_backend = "8087";
|
|
|
|
in {
|
|
|
|
|
|
|
|
imports = [
|
|
|
|
../acme.nix
|
|
|
|
../dns.nix
|
|
|
|
../nginx.nix
|
2023-07-21 20:56:19 +00:00
|
|
|
inputs.skynet_ldap_backend.nixosModule."x86_64-linux"
|
2023-06-18 21:49:31 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
options.services.ldap_backend = {
|
|
|
|
enable = mkEnableOption "Skynet LDAP backend server";
|
|
|
|
|
|
|
|
host = {
|
|
|
|
ip = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
domain = {
|
|
|
|
tld = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "ie";
|
|
|
|
};
|
|
|
|
|
|
|
|
base = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "skynet";
|
|
|
|
};
|
|
|
|
|
|
|
|
sub = mkOption {
|
|
|
|
type = types.str;
|
2023-08-06 18:00:02 +00:00
|
|
|
default = "api.account";
|
2023-06-18 21:49:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
#backups = [ "/etc/silver_ul_ical/database.db" ];
|
|
|
|
|
|
|
|
age.secrets.ldap_self_service.file = ../../secrets/ldap/self_service.age;
|
2023-08-27 21:31:08 +00:00
|
|
|
age.secrets.ldap_discord.file = ../../secrets/discord/ldap.age;
|
2023-06-18 21:49:31 +00:00
|
|
|
|
2023-08-06 19:09:15 +00:00
|
|
|
skynet_acme.domains = [
|
|
|
|
"${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}"
|
|
|
|
];
|
|
|
|
|
2023-07-16 00:53:21 +00:00
|
|
|
skynet_dns.records = [
|
|
|
|
{record=cfg.domain.sub; r_type="CNAME"; value=cfg.host.name;}
|
2023-06-18 21:49:31 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
locations."/".proxyPass = "http://localhost:${port_backend}";
|
2023-07-27 23:05:11 +00:00
|
|
|
|
|
|
|
extraConfig = ''
|
2023-08-06 18:00:02 +00:00
|
|
|
add_header Access-Control-Allow-Origin "https://account.${cfg.domain.base}.${cfg.domain.tld}";
|
2023-07-27 23:05:11 +00:00
|
|
|
'';
|
2023-06-18 21:49:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
services.skynet_ldap_backend = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
# contains teh password in env form
|
2023-08-27 21:31:08 +00:00
|
|
|
env = {
|
|
|
|
ldap = config.age.secrets.ldap_self_service.path;
|
|
|
|
discord = config.age.secrets.ldap_discord.path;
|
|
|
|
};
|
2023-06-18 21:49:31 +00:00
|
|
|
|
|
|
|
ldap = {
|
2023-08-06 18:00:02 +00:00
|
|
|
host = "ldaps://account.skynet.ie";
|
2023-07-30 22:08:11 +00:00
|
|
|
admin = "uid=ldap_api,ou=users,dc=skynet,dc=ie";
|
2023-06-18 21:49:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
users = {
|
|
|
|
admin = [
|
|
|
|
"silver"
|
|
|
|
"evanc"
|
|
|
|
"eoghanconlon73"
|
|
|
|
];
|
|
|
|
committee = [
|
2023-07-30 02:13:49 +00:00
|
|
|
"grym"
|
2023-08-07 15:54:41 +00:00
|
|
|
"dawidk5"
|
|
|
|
"leo"
|
2023-06-18 21:49:31 +00:00
|
|
|
"silver"
|
|
|
|
"eoghanconlon73"
|
|
|
|
];
|
|
|
|
lifetime = [];
|
|
|
|
banned = [];
|
|
|
|
};
|
|
|
|
|
|
|
|
host_port = "127.0.0.1:${port_backend}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|