2020-04-24 23:36:52 +00:00
|
|
|
{config, lib, ...}:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) mkOption mkIf types length attrNames;
|
|
|
|
cfg = config.services.kerberos_server;
|
2024-01-13 08:15:51 +00:00
|
|
|
kerberos = config.security.krb5.package;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
aclEntry = {
|
|
|
|
options = {
|
|
|
|
principal = mkOption {
|
|
|
|
type = types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Which principal the rule applies to";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
access = mkOption {
|
|
|
|
type = types.either
|
|
|
|
(types.listOf (types.enum ["add" "cpw" "delete" "get" "list" "modify"]))
|
|
|
|
(types.enum ["all"]);
|
|
|
|
default = "all";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "The changes the principal is allowed to make.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
target = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "*";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "The principals that 'access' applies to.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
realm = {
|
|
|
|
options = {
|
|
|
|
acl = mkOption {
|
|
|
|
type = types.listOf (types.submodule aclEntry);
|
|
|
|
default = [
|
|
|
|
{ principal = "*/admin"; access = "all"; }
|
|
|
|
{ principal = "admin"; access = "all"; }
|
|
|
|
];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The privileges granted to a user.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
./mit.nix
|
|
|
|
./heimdal.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.kerberos_server = {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = lib.mkEnableOption "the kerberos authentication server";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
realms = mkOption {
|
|
|
|
type = types.attrsOf (types.submodule realm);
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The realm(s) to serve keys for.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ kerberos ];
|
|
|
|
assertions = [{
|
|
|
|
assertion = length (attrNames cfg.realms) <= 1;
|
|
|
|
message = "Only one realm per server is currently supported.";
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
}
|