2020-06-08 02:08:41 +02:00
|
|
|
# Configures an OpenLDAP instance for TVL
|
|
|
|
#
|
|
|
|
# TODO(tazjin): Configure ldaps://
|
2021-04-02 14:18:50 +02:00
|
|
|
{ depot, lib, pkgs, ... }:
|
2020-06-08 02:08:41 +02:00
|
|
|
|
2021-04-02 14:18:50 +02:00
|
|
|
with depot.nix.yants;
|
2020-06-17 04:48:21 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
user = struct {
|
|
|
|
username = string;
|
|
|
|
email = string;
|
|
|
|
password = string;
|
|
|
|
displayName = option string;
|
|
|
|
};
|
|
|
|
|
|
|
|
toLdif = defun [ user string ] (u: ''
|
|
|
|
dn: cn=${u.username},ou=users,dc=tvl,dc=fyi
|
|
|
|
objectClass: organizationalPerson
|
|
|
|
objectClass: inetOrgPerson
|
|
|
|
sn: ${u.username}
|
|
|
|
cn: ${u.username}
|
|
|
|
displayName: ${u.displayName or u.username}
|
|
|
|
mail: ${u.email}
|
|
|
|
userPassword: ${u.password}
|
|
|
|
'');
|
|
|
|
|
2021-04-02 14:18:50 +02:00
|
|
|
inherit (depot.ops) users;
|
2021-01-18 12:10:33 +01:00
|
|
|
|
2020-06-17 04:48:21 +02:00
|
|
|
in
|
|
|
|
{
|
2020-06-08 02:08:41 +02:00
|
|
|
services.openldap = {
|
|
|
|
enable = true;
|
|
|
|
|
2020-12-25 11:13:06 +01:00
|
|
|
settings.children = {
|
|
|
|
"olcDatabase={1}mdb".attrs = {
|
|
|
|
objectClass = [ "olcDatabaseConfig" "olcMdbConfig" ];
|
|
|
|
olcDatabase = "{1}mdb";
|
2021-05-25 00:26:34 +02:00
|
|
|
olcDbDirectory = "/var/lib/openldap";
|
2020-12-25 11:13:06 +01:00
|
|
|
olcSuffix = "dc=tvl,dc=fyi";
|
|
|
|
olcAccess = "to * by * read";
|
2021-05-25 00:26:34 +02:00
|
|
|
olcRootDN = "cn=admin,dc=tvl,dc=fyi";
|
|
|
|
olcRootPW = "{ARGON2}$argon2id$v=19$m=65536,t=2,p=1$OfcgkOQ96VQ3aJj7NfA9vQ$oS6HQOkYl/bUYg4SejpltQYy7kvqx/RUxvoR4zo1vXU";
|
2020-12-25 11:13:06 +01:00
|
|
|
};
|
2020-06-08 02:08:41 +02:00
|
|
|
|
2020-12-25 11:13:06 +01:00
|
|
|
"cn=module{0}".attrs = {
|
|
|
|
objectClass = "olcModuleList";
|
2022-05-28 01:01:15 +02:00
|
|
|
olcModuleLoad = "argon2";
|
2020-12-25 11:13:06 +01:00
|
|
|
};
|
2021-05-25 00:26:34 +02:00
|
|
|
|
|
|
|
"cn=schema".includes =
|
2021-04-13 12:21:42 +02:00
|
|
|
map (schema: "${pkgs.openldap}/etc/schema/${schema}.ldif")
|
2021-05-25 00:26:34 +02:00
|
|
|
[ "core" "cosine" "inetorgperson" "nis" ];
|
2020-12-25 11:13:06 +01:00
|
|
|
};
|
2020-07-01 20:24:49 +02:00
|
|
|
|
2020-06-17 04:48:21 +02:00
|
|
|
# Contents are immutable at runtime, and adding user accounts etc.
|
|
|
|
# is done statically in the LDIF-formatted contents in this folder.
|
2020-12-25 11:13:06 +01:00
|
|
|
declarativeContents."dc=tvl,dc=fyi" = ''
|
2020-06-17 04:48:21 +02:00
|
|
|
dn: dc=tvl,dc=fyi
|
|
|
|
dc: tvl
|
|
|
|
o: TVL LDAP server
|
|
|
|
description: Root entry for tvl.fyi
|
|
|
|
objectClass: top
|
|
|
|
objectClass: dcObject
|
|
|
|
objectClass: organization
|
|
|
|
|
|
|
|
dn: ou=users,dc=tvl,dc=fyi
|
|
|
|
ou: users
|
|
|
|
description: All users in TVL
|
|
|
|
objectClass: top
|
|
|
|
objectClass: organizationalUnit
|
|
|
|
|
|
|
|
dn: ou=groups,dc=tvl,dc=fyi
|
|
|
|
ou: groups
|
|
|
|
description: All groups in TVL
|
|
|
|
objectClass: top
|
|
|
|
objectClass: organizationalUnit
|
|
|
|
|
|
|
|
${lib.concatStringsSep "\n" (map toLdif users)}
|
|
|
|
'';
|
2020-06-08 02:08:41 +02:00
|
|
|
};
|
|
|
|
}
|