2024-03-05 15:10:20 +01:00
|
|
|
{ config, lib, pkgs, nixpkgs-unstable, system, ... }:
|
2022-12-17 17:42:10 +01:00
|
|
|
let
|
2023-09-17 20:10:55 +02:00
|
|
|
domain = "auth.${config.networking.domain}";
|
2024-03-05 15:10:20 +01:00
|
|
|
seedSettings = {
|
2023-07-07 17:13:17 +02:00
|
|
|
groups = [
|
|
|
|
{
|
|
|
|
name = "admins";
|
|
|
|
long_name = "Portunus Admin";
|
|
|
|
members = [ "admin" ];
|
|
|
|
permissions.portunus.is_admin = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "search";
|
|
|
|
long_name = "LDAP search group";
|
|
|
|
members = [ "search" ];
|
|
|
|
permissions.ldap.can_read = true;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "fsr";
|
|
|
|
long_name = "Mitglieder des iFSR";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
users = [
|
|
|
|
{
|
|
|
|
login_name = "admin";
|
|
|
|
given_name = "admin";
|
|
|
|
family_name = "admin";
|
|
|
|
password.from_command = [
|
|
|
|
"${pkgs.coreutils}/bin/cat"
|
|
|
|
config.sops.secrets."portunus/admin-password".path
|
|
|
|
];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
login_name = "search";
|
|
|
|
given_name = "search";
|
|
|
|
family_name = "search";
|
|
|
|
password.from_command = [
|
|
|
|
"${pkgs.coreutils}/bin/cat"
|
|
|
|
config.sops.secrets."portunus/search-password".path
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2022-12-17 17:42:10 +01:00
|
|
|
in
|
|
|
|
{
|
2024-03-05 15:10:20 +01:00
|
|
|
# Use portunus from unstable branch until 24.05 is here
|
|
|
|
disabledModules = [ "services/misc/portunus.nix" ];
|
|
|
|
imports = [ "${nixpkgs-unstable}/nixos/modules/services/misc/portunus.nix" ];
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
(self: super: {
|
|
|
|
inherit (nixpkgs-unstable.legacyPackages.${system}) portunus;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-01-18 14:12:03 +01:00
|
|
|
sops.secrets = {
|
2023-07-07 17:12:59 +02:00
|
|
|
"portunus/admin-password".owner = config.services.portunus.user;
|
|
|
|
"portunus/search-password".owner = config.services.portunus.user;
|
|
|
|
"dex/environment".owner = config.systemd.services.dex.serviceConfig.User;
|
2022-12-02 14:25:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.portunus = {
|
|
|
|
enable = true;
|
2023-09-17 20:14:32 +02:00
|
|
|
package = pkgs.portunus.overrideAttrs (_old: {
|
2023-07-23 22:28:16 +02:00
|
|
|
patches = [
|
|
|
|
./0001-update-user-validation-regex.patch
|
|
|
|
./0002-both-ldap-and-ldaps.patch
|
2023-09-01 00:14:41 +02:00
|
|
|
./0003-gecos-ascii-escape.patch
|
2023-09-15 13:26:45 +02:00
|
|
|
./0004-make-givenName-optional.patch
|
2023-07-23 22:28:16 +02:00
|
|
|
];
|
2024-03-05 15:10:20 +01:00
|
|
|
doCheck = false; # posix regex related tests break
|
2023-07-04 17:06:18 +02:00
|
|
|
});
|
2023-01-18 14:12:03 +01:00
|
|
|
|
2024-03-05 15:10:20 +01:00
|
|
|
inherit domain seedSettings;
|
2023-07-07 17:12:59 +02:00
|
|
|
port = 8681;
|
|
|
|
dex.enable = true;
|
2023-01-18 14:12:03 +01:00
|
|
|
|
2023-07-07 17:12:59 +02:00
|
|
|
ldap = {
|
2022-12-17 19:21:16 +01:00
|
|
|
suffix = "dc=ifsr,dc=de";
|
2023-01-18 14:12:03 +01:00
|
|
|
searchUserName = "search";
|
|
|
|
|
2023-07-23 22:28:16 +02:00
|
|
|
# normally disables port 389 (but not with our patch), use 636 with tls
|
2023-01-18 14:12:03 +01:00
|
|
|
# `portunus.domain` resolves to localhost
|
2023-07-23 22:28:16 +02:00
|
|
|
tls = true;
|
2022-12-02 14:25:55 +01:00
|
|
|
};
|
2023-07-07 17:12:59 +02:00
|
|
|
};
|
2022-12-02 14:25:55 +01:00
|
|
|
|
2024-03-05 15:10:20 +01:00
|
|
|
services.dex.settings = {
|
|
|
|
oauth2.skipApprovalScreen = true;
|
|
|
|
frontend = {
|
|
|
|
issuer = "iFSR Schliboleth";
|
|
|
|
logoURL = "https://wiki.ifsr.de/images/3/3b/LogoiFSR.png";
|
|
|
|
theme = "dark";
|
|
|
|
};
|
|
|
|
};
|
2023-07-07 17:12:59 +02:00
|
|
|
|
|
|
|
systemd.services.dex.serviceConfig = {
|
|
|
|
DynamicUser = lib.mkForce false;
|
|
|
|
EnvironmentFile = config.sops.secrets."dex/environment".path;
|
|
|
|
StateDirectory = "dex";
|
|
|
|
User = "dex";
|
2022-12-02 14:25:55 +01:00
|
|
|
};
|
|
|
|
|
2023-07-07 17:12:59 +02:00
|
|
|
users = {
|
|
|
|
users.dex = {
|
|
|
|
group = "dex";
|
|
|
|
isSystemUser = true;
|
2023-02-15 11:29:47 +01:00
|
|
|
};
|
2023-07-07 17:12:59 +02:00
|
|
|
groups.dex = { };
|
|
|
|
};
|
2023-02-03 15:40:42 +01:00
|
|
|
|
2023-08-22 15:25:33 +02:00
|
|
|
security.pam.services.sshd.makeHomeDir = true;
|
2023-02-15 11:29:47 +01:00
|
|
|
|
2022-12-17 13:58:06 +01:00
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts."${config.services.portunus.domain}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
locations = {
|
|
|
|
"/".proxyPass = "http://localhost:${toString config.services.portunus.port}";
|
2023-07-07 17:12:59 +02:00
|
|
|
"/dex".proxyPass = "http://localhost:${toString config.services.portunus.dex.port}";
|
2022-12-17 13:58:06 +01:00
|
|
|
};
|
|
|
|
};
|
2022-12-02 14:25:55 +01:00
|
|
|
};
|
2023-11-28 23:00:41 +01:00
|
|
|
networking.firewall = {
|
|
|
|
extraInputRules = ''
|
|
|
|
ip saddr { 141.30.86.192/26, 141.76.100.128/25 } tcp dport 636 accept comment "Allow ldaps access from office nets"
|
|
|
|
'';
|
|
|
|
};
|
2022-12-02 14:25:55 +01:00
|
|
|
}
|