2023-05-16 21:23:04 +00:00
|
|
|
/*
|
|
|
|
Gonna use a priper nixos module for this
|
|
|
|
*/
|
|
|
|
|
2023-05-18 20:59:23 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
2023-05-16 21:23:04 +00:00
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.skynet_ldap;
|
2023-05-20 02:08:30 +00:00
|
|
|
base = "dc=skynet,dc=ie";
|
2023-05-16 21:23:04 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
# these are needed for teh program in question
|
|
|
|
imports = [
|
|
|
|
./acme.nix
|
|
|
|
./nginx.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
options.services.skynet_ldap = {
|
|
|
|
# options that need to be passed in to make this work
|
|
|
|
|
|
|
|
enable = mkEnableOption "Skynet LDAP service";
|
|
|
|
|
|
|
|
host = {
|
|
|
|
ip = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
subdomain = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "sso";
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 8080;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# this is athe actual configuration that we need to do
|
|
|
|
|
2023-05-20 23:19:20 +00:00
|
|
|
# after changing teh password openldap.service has to be restarted
|
|
|
|
age.secrets.ldap_pw = {
|
|
|
|
file = ../secrets/ldap/pw.age;
|
|
|
|
mode = "440";
|
|
|
|
owner = "openldap";
|
|
|
|
group = "openldap";
|
|
|
|
};
|
|
|
|
|
|
|
|
# openldap
|
2023-05-20 21:20:06 +00:00
|
|
|
age.secrets.ldap_self_service.file = ../secrets/ldap/self_service.age;
|
2023-05-20 20:33:04 +00:00
|
|
|
|
2023-05-16 21:23:04 +00:00
|
|
|
skynet_dns.records.cname = [
|
|
|
|
"${cfg.subdomain} CNAME ${cfg.host.name}"
|
|
|
|
];
|
|
|
|
|
|
|
|
# firewall on teh computer itself
|
|
|
|
networking.firewall.allowedTCPPorts = [
|
|
|
|
80
|
|
|
|
443
|
2023-05-18 20:59:23 +00:00
|
|
|
|
|
|
|
# for ldap
|
|
|
|
389
|
2023-05-16 21:23:04 +00:00
|
|
|
];
|
|
|
|
|
2023-05-20 02:08:30 +00:00
|
|
|
services.openldap = {
|
|
|
|
enable = true;
|
2023-05-16 21:23:04 +00:00
|
|
|
|
2023-05-20 02:08:30 +00:00
|
|
|
/* enable plain connections only */
|
|
|
|
urlList = [ "ldap:///" ];
|
2023-05-16 21:23:04 +00:00
|
|
|
|
|
|
|
|
2023-05-20 02:08:30 +00:00
|
|
|
settings = {
|
|
|
|
attrs = {
|
|
|
|
olcLogLevel = "conns config";
|
|
|
|
};
|
2023-05-16 21:23:04 +00:00
|
|
|
|
2023-05-20 02:08:30 +00:00
|
|
|
children = {
|
|
|
|
"cn=schema".includes = [
|
|
|
|
"${pkgs.openldap}/etc/schema/core.ldif"
|
|
|
|
"${pkgs.openldap}/etc/schema/cosine.ldif"
|
|
|
|
"${pkgs.openldap}/etc/schema/inetorgperson.ldif"
|
|
|
|
"${pkgs.openldap}/etc/schema/nis.ldif"
|
|
|
|
./ldap/openssh-lpk.ldif
|
2023-05-20 14:26:03 +00:00
|
|
|
./ldap/skMemberOf.ldif
|
2023-05-20 02:08:30 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
2023-05-20 14:26:03 +00:00
|
|
|
"cn=modules".attrs = {
|
|
|
|
objectClass = [ "olcModuleList" ];
|
|
|
|
cn = "modules";
|
|
|
|
olcModuleLoad = ["dynlist" "memberof"];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
"olcDatabase={1}mdb" = {
|
|
|
|
attrs = {
|
|
|
|
objectClass = [ "olcDatabaseConfig" "olcMdbConfig" ];
|
|
|
|
|
|
|
|
olcDatabase = "{1}mdb";
|
|
|
|
olcDbDirectory = "/var/lib/openldap/data";
|
|
|
|
|
|
|
|
olcSuffix = base;
|
2023-05-20 02:08:30 +00:00
|
|
|
|
2023-05-20 14:26:03 +00:00
|
|
|
/* your admin account, do not use writeText on a production system */
|
|
|
|
olcRootDN = "cn=admin,${base}";
|
2023-05-20 20:33:04 +00:00
|
|
|
olcRootPW.path = config.age.secrets.ldap_pw.path;
|
2023-05-20 02:08:30 +00:00
|
|
|
|
2023-05-20 14:26:03 +00:00
|
|
|
#olcOverlay = "memberof";
|
2023-05-20 02:08:30 +00:00
|
|
|
|
2023-05-20 14:26:03 +00:00
|
|
|
olcAccess = [
|
|
|
|
/* custom access rules for userPassword attributes */
|
|
|
|
''{0}to attrs=userPassword
|
|
|
|
by self write
|
|
|
|
by anonymous auth
|
|
|
|
by * none''
|
|
|
|
|
|
|
|
/* allow read on anything else */
|
|
|
|
''{1}to *
|
|
|
|
by * read''
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
# https://blog.oddbit.com/post/2013-07-22-generating-a-membero/
|
|
|
|
children = {
|
|
|
|
"olcOverlay=dynlist".attrs = {
|
|
|
|
objectClass = [ "olcOverlayConfig" "olcDynamicList" ];
|
|
|
|
olcOverlay = "dynlist";
|
|
|
|
olcDlAttrSet = "skPerson labeledURI skMemberOf";
|
|
|
|
};
|
|
|
|
};
|
2023-05-20 02:08:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
};
|
2023-05-20 14:26:03 +00:00
|
|
|
|
2023-05-20 02:08:30 +00:00
|
|
|
};
|
2023-05-18 20:59:23 +00:00
|
|
|
};
|
2023-05-16 21:23:04 +00:00
|
|
|
};
|
2023-05-20 02:08:30 +00:00
|
|
|
|
2023-05-20 18:33:08 +00:00
|
|
|
|
|
|
|
services.nginx.virtualHosts."${cfg.subdomain}.skynet.ie" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
locations."/".proxyPass = "http://localhost:8888";
|
|
|
|
};
|
|
|
|
|
|
|
|
virtualisation.arion = {
|
|
|
|
backend = "docker";
|
|
|
|
projects = {
|
|
|
|
ldap_reset.settings.services.ldap_reset.service = {
|
|
|
|
image = "docker.io/ltbproject/self-service-password:1.5.3";
|
|
|
|
# setting these here as they arent special
|
|
|
|
environment = {
|
|
|
|
# this is what it last ran on
|
|
|
|
SPIGOT_VER="1.18.2";
|
|
|
|
EULA="true";
|
|
|
|
};
|
|
|
|
|
|
|
|
# where the config files are stored
|
|
|
|
volumes = [
|
2023-05-20 20:33:04 +00:00
|
|
|
"${config.age.secrets.ldap_self_service.path}:/var/www/conf/config.inc.local.php"
|
2023-05-20 18:33:08 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
ports = [
|
|
|
|
"8888:80/tcp"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-05-16 21:23:04 +00:00
|
|
|
};
|
|
|
|
}
|