add yubikey config
This commit is contained in:
@@ -22,6 +22,7 @@ in
|
|||||||
backups.repo = "/holocron/archives/servers/snowbelle";
|
backups.repo = "/holocron/archives/servers/snowbelle";
|
||||||
sops.enable = true;
|
sops.enable = true;
|
||||||
podman.enable = true;
|
podman.enable = true;
|
||||||
|
yubikey.enable = true;
|
||||||
syncthing.enable = true;
|
syncthing.enable = true;
|
||||||
tailscale.enable = true;
|
tailscale.enable = true;
|
||||||
nvidia.enable = true;
|
nvidia.enable = true;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
./sops
|
./sops
|
||||||
./docker
|
./docker
|
||||||
./podman
|
./podman
|
||||||
|
./yubikey
|
||||||
./tailscale
|
./tailscale
|
||||||
./vpns
|
./vpns
|
||||||
./vpn-confinement
|
./vpn-confinement
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
service = "";
|
service = "yubikey";
|
||||||
cfg = config.system.${service};
|
cfg = config.system.${service};
|
||||||
sec = config.sops.secrets;
|
sec = config.sops.secrets;
|
||||||
homelab = config.homelab;
|
homelab = config.homelab;
|
||||||
@@ -14,9 +14,41 @@ in
|
|||||||
{
|
{
|
||||||
options.system.${service} = {
|
options.system.${service} = {
|
||||||
enable = lib.mkEnableOption "enables ${service}";
|
enable = lib.mkEnableOption "enables ${service}";
|
||||||
|
mode = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "u2f";
|
||||||
|
description = "weather to run pam in u2f or challenge-response)";
|
||||||
|
};
|
||||||
|
lock_on_remove = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "enable automatic locking of device upon removal of yubikey";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
|
||||||
|
security.pam.services = lib.mkIf (cfg.mode == "u2f") {
|
||||||
|
login.u2fAuth = true;
|
||||||
|
sudo.u2fAuth = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
security.pam.yubico = lib.mkIf (cfg.mode == "challenge-response") {
|
||||||
|
enable = true;
|
||||||
|
debug = true;
|
||||||
|
mode = "challenge-response";
|
||||||
|
id = [ "<placeholder>" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.udev.extraRules = lib.mkIf (cfg.lock_on_remove == true) ''
|
||||||
|
ACTION=="remove",\
|
||||||
|
ENV{ID_BUS}=="usb",\
|
||||||
|
ENV{ID_MODEL_ID}=="0407",\
|
||||||
|
ENV{ID_VENDOR_ID}=="1050",\
|
||||||
|
ENV{ID_VENDOR}=="Yubico",\
|
||||||
|
RUN+="${pkgs.systemd}/bin/loginctl lock-sessions"
|
||||||
|
'';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user