-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nixos/web-servers: assert ACME cert access via service user and groups
Allows giving access using SupplementaryGroups.
- Loading branch information
1 parent
a4abee1
commit ecb28d1
Showing
4 changed files
with
28 additions
and
11 deletions.
There are no files selected for viewing
23 changes: 20 additions & 3 deletions
23
nixos/modules/security/acme/mk-cert-ownership-assertion.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
{ cert, group, groups, user }: { | ||
assertion = cert.group == group || builtins.any (u: u == user) groups.${cert.group}.members; | ||
message = "Group for certificate ${cert.domain} must be ${group}, or user ${user} must be a member of group ${cert.group}"; | ||
lib: | ||
|
||
{ cert, groups, services }: | ||
let | ||
catSep = builtins.concatStringsSep; | ||
|
||
svcGroups = svc: | ||
(lib.optional (svc.serviceConfig ? Group) svc.serviceConfig.Group) | ||
++ (svc.serviceConfig.SupplementaryGroups or [ ]); | ||
in | ||
{ | ||
assertion = builtins.all (svc: | ||
svc.serviceConfig.User or "root" == "root" | ||
|| builtins.elem svc.serviceConfig.User groups.${cert.group}.members | ||
|| builtins.elem cert.group (svcGroups svc) | ||
) services; | ||
|
||
message = "Certificate ${cert.domain} (group=${cert.group}) must be readable by service(s) ${ | ||
catSep ", " (map (svc: "${svc.name} (user=${svc.serviceConfig.User} groups=${catSep " " (svcGroups svc)})") services) | ||
}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters