X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fprivate%2Fdatabases%2Fopenldap%2Fdefault.nix;h=e00f4c2af03b4201196224c2e4d150bc6c2e309e;hb=3d11eafc9c516321901908338befe4c04b58f3aa;hp=e048d565200f532eaddfa6c4ab8eb7ce3112254e;hpb=4aac110f17f0528d90510eec00c9a8df60bcf04f;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/databases/openldap/default.nix b/modules/private/databases/openldap/default.nix index e048d56..e00f4c2 100644 --- a/modules/private/databases/openldap/default.nix +++ b/modules/private/databases/openldap/default.nix @@ -2,22 +2,9 @@ let cfg = config.myServices.databases.openldap; ldapConfig = let - kerberosSchema = pkgs.fetchurl { - url = "https://raw.githubusercontent.com/krb5/krb5/master/src/plugins/kdb/ldap/libkdb_ldap/kerberos.schema"; - sha256 = "17fnkkf6s3lznsl7wp6914pqsc78d038rh38l638big8z608ksww"; - }; - puppetSchema = pkgs.fetchurl { - url = "https://raw.githubusercontent.com/puppetlabs/puppet/master/ext/ldap/puppet.schema"; - sha256 = "11bjf5zfvqlim7p9vddcafs0wiq3v8ys77x8h6fbp9c6bdfh0awh"; - }; + eldiron_schemas = pkgs.callPackage ./eldiron_schemas.nix {}; in '' - include ${pkgs.openldap}/etc/schema/core.schema - include ${pkgs.openldap}/etc/schema/cosine.schema - include ${pkgs.openldap}/etc/schema/inetorgperson.schema - include ${pkgs.openldap}/etc/schema/nis.schema - include ${puppetSchema} - include ${kerberosSchema} - include ${./immae.schema} + ${eldiron_schemas} pidfile ${cfg.pids.pid} argsfile ${cfg.pids.args} @@ -25,30 +12,21 @@ let moduleload back_hdb backend hdb - moduleload memberof - database hdb - suffix "${cfg.baseDn}" - rootdn "${cfg.rootDn}" - include ${config.secrets.location}/ldap/password - directory ${cfg.dataDir} - overlay memberof - - TLSCertificateFile ${config.security.acme.directory}/ldap/cert.pem - TLSCertificateKeyFile ${config.security.acme.directory}/ldap/key.pem - TLSCACertificateFile ${config.security.acme.directory}/ldap/fullchain.pem + TLSCertificateFile ${config.security.acme.certs.ldap.directory}/cert.pem + TLSCertificateKeyFile ${config.security.acme.certs.ldap.directory}/key.pem + TLSCACertificateFile ${config.security.acme.certs.ldap.directory}/fullchain.pem TLSCACertificatePath ${pkgs.cacert.unbundled}/etc/ssl/certs/ #This makes openldap crash #TLSCipherSuite DEFAULT sasl-host kerberos.immae.eu - include ${config.secrets.location}/ldap/access ''; in { options.myServices.databases = { openldap = { enable = lib.mkOption { - default = cfg.enable; + default = false; example = true; description = "Whether to enable ldap"; type = lib.types.bool; @@ -126,29 +104,40 @@ in users.users.openldap.extraGroups = [ "keys" ]; networking.firewall.allowedTCPPorts = [ 636 389 ]; - services.cron = { - systemCronJobs = [ - '' - 35 1,13 * * * root ${pkgs.openldap}/bin/slapcat -v -b "dc=immae,dc=eu" -f ${pkgs.writeText "slapd.conf" ldapConfig} -l ${cfg.dataDir}/backup.ldif | ${pkgs.gnugrep}/bin/grep -v "^# id=[0-9a-f]*$" - '' - ]; - }; - security.acme.certs."ldap" = config.myServices.databasesCerts // { user = "openldap"; group = "openldap"; - plugins = [ "fullchain.pem" "key.pem" "cert.pem" "account_key.json" ]; domain = "ldap.immae.eu"; postRun = '' systemctl restart openldap.service ''; }; + services.filesWatcher.openldap = { + restart = true; + paths = [ "${config.secrets.location}/ldap/" ]; + }; + services.openldap = { enable = true; dataDir = cfg.dataDir; urlList = [ "ldap://" "ldaps://" ]; + logLevel = "none"; extraConfig = ldapConfig; + extraDatabaseConfig = '' + moduleload memberof + overlay memberof + + moduleload syncprov + overlay syncprov + syncprov-checkpoint 100 10 + + include ${config.secrets.location}/ldap/access + ''; + rootpwFile = "${config.secrets.location}/ldap/password"; + suffix = cfg.baseDn; + rootdn = cfg.rootDn; + database = "hdb"; }; }; }