diff --git a/machines/gerd/services/authelia.nix b/machines/gerd/services/authelia.nix index 3587a36..be6f010 100644 --- a/machines/gerd/services/authelia.nix +++ b/machines/gerd/services/authelia.nix @@ -1,6 +1,8 @@ { config, ... }: let + svc_domain = "auth.${config.mine.settings.domain}"; + autheliaStateDir = "/var/lib/authelia-main"; in { services.authelia.instances.main = { @@ -16,7 +18,7 @@ in { settings = { access_control.default_policy = "one_factor"; - session.domain = "fricloud.dk"; + session.domain = config.mine.settings.domain; storage.local.path = "${autheliaStateDir}/authelia.sqlite3"; notifier.filesystem.filename = "${autheliaStateDir}/authelia_notifier.txt"; @@ -33,19 +35,19 @@ in { timeout = "5s"; start_tls = false; - base_dn = "dc=fricloud,dc=dk"; - additional_users_dn = "ou=people"; + base_dn = config.mine.settings.ldap.dc; + additional_users_dn = "ou=${config.mine.settings.ldap.ou.users}"; + additional_groups_dn = "ou=${config.mine.settings.ldap.ou.groups}"; users_filter = "(&(|({username_attribute}={input})({mail_attribute}={input}))(objectClass=person))"; - additional_groups_dn = "ou=groups"; groups_filter = "(member={dn})"; - display_name_attribute = "displayName"; - username_attribute = "uid"; - group_name_attribute = "cn"; - mail_attribute = "mail"; + display_name_attribute = config.mine.settings.ldap.attr.firstname; + username_attribute = config.mine.settings.ldap.attr.uid; + group_name_attribute = config.mine.settings.ldap.attr.groupname; + mail_attribute = config.mine.settings.ldap.attr.email; - user = "uid=bind_user,ou=people,dc=fricloud,dc=dk"; + user = config.mine.settings.ldap.bind_dn; }; }; }; @@ -74,7 +76,7 @@ in { # }]; - services.nginx.virtualHosts."auth.fricloud.dk" = { + services.nginx.virtualHosts."${svc_domain}" = { forceSSL = true; enableACME = true; locations."/".proxyPass = "http://localhost:${builtins.toString config.services.authelia.instances.main.settings.server.port}"; diff --git a/machines/gerd/services/forgejo.nix b/machines/gerd/services/forgejo.nix index 64ee69e..3b91f8b 100644 --- a/machines/gerd/services/forgejo.nix +++ b/machines/gerd/services/forgejo.nix @@ -1,6 +1,8 @@ { config, lib, pkgs, ... }: let + svc_domain = "git.${config.mine.settings.domain}"; + scriptAddLDAPAuth = pkgs.writeShellScript "forgejo-add-update-ldap-auth.sh" '' #!/usr/bin/env sh FORGEJO_WORK_PATH="${config.services.forgejo.stateDir}" @@ -54,8 +56,8 @@ in { settings = { server = { - DOMAIN = "git.fricloud.dk"; - ROOT_URL = "https://git.fricloud.dk"; + DOMAIN = svc_domain; + ROOT_URL = "https://${svc_domain}"; HTTPPORT = 3000; }; @@ -78,7 +80,7 @@ in { # already issued for this exact set of domains in the last 168 hours: git.fricloud.dk, retry after 2024-08-10T01:34:44Z security.acme.certs."git.fricloud.dk".extraDomainNames = [ "git2.fricloud.dk" ]; - services.nginx.virtualHosts."git.fricloud.dk" = { + services.nginx.virtualHosts."${svc_domain}" = { forceSSL = true; enableACME = true; extraConfig = '' diff --git a/machines/gerd/services/fricloud-website.nix b/machines/gerd/services/fricloud-website.nix index 9f79ada..2efde48 100644 --- a/machines/gerd/services/fricloud-website.nix +++ b/machines/gerd/services/fricloud-website.nix @@ -1,13 +1,15 @@ { config, pkgs, ... }: -{ - services.nginx.virtualHosts."fricloud.dk" = { +let + svc_domain = config.mine.settings.domain; +in { + services.nginx.virtualHosts."${svc_domain}" = { forceSSL = true; enableACME = true; root = pkgs.writeTextDir "index.html" ''
-