Compare commits
2 commits
0fe23e8bf8
...
2d9136b189
Author | SHA1 | Date | |
---|---|---|---|
2d9136b189 | |||
8e0a030085 |
4 changed files with 72 additions and 26 deletions
|
@ -1,9 +1,12 @@
|
||||||
{
|
{
|
||||||
boot.loader.grub = {
|
boot.loader = {
|
||||||
enable = true;
|
timeout = 1;
|
||||||
device = "nodev";
|
grub = {
|
||||||
efiSupport = true;
|
enable = true;
|
||||||
efiInstallAsRemovable = true;
|
device = "nodev";
|
||||||
enableCryptodisk = true;
|
efiSupport = true;
|
||||||
|
efiInstallAsRemovable = true;
|
||||||
|
enableCryptodisk = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,11 @@
|
||||||
./users
|
./users
|
||||||
];
|
];
|
||||||
|
|
||||||
local.yubikey.enable = true;
|
local.yubikey = {
|
||||||
|
enable = true;
|
||||||
|
serial = "28058247";
|
||||||
|
unplug.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Services
|
# Services
|
||||||
|
|
|
@ -11,7 +11,7 @@ in
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
programs.i3lock = {
|
programs.i3lock = {
|
||||||
enable = true;
|
enable = true;
|
||||||
u2fSupport = lib.mkDefault config.local.yubikey.enable;
|
u2fSupport = lib.mkDefault config.security.pam.u2f.enable;
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.xss-lock.enable = true;
|
programs.xss-lock.enable = true;
|
||||||
|
|
|
@ -1,32 +1,71 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
let cfg = config.local.yubikey; in
|
let
|
||||||
|
cfg = config.local.yubikey;
|
||||||
|
|
||||||
|
control = if cfg.multi-factor.enable then "required" else "sufficient";
|
||||||
|
in
|
||||||
{
|
{
|
||||||
options.local.yubikey = with lib; {
|
options.local.yubikey = with lib; {
|
||||||
enable = mkEnableOption "yubikey";
|
enable = mkEnableOption "yubikey";
|
||||||
|
|
||||||
|
serial = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
multi-factor.enable = mkEnableOption "multi-factor" // { default = true; };
|
||||||
|
|
||||||
|
unplug = {
|
||||||
|
enable = mkEnableOption "Do action when a Yubikey is unplugged";
|
||||||
|
model = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "407";
|
||||||
|
};
|
||||||
|
command = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "${pkgs.systemd}/bin/loginctl lock-sessions";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
environment.systemPackages = [ pkgs.yubikey-manager pkgs.yubikey-personalization ];
|
environment.systemPackages = [ pkgs.yubikey-manager pkgs.yubikey-personalization ];
|
||||||
|
|
||||||
security.pam.u2f = {
|
security.pam =
|
||||||
enable = true;
|
if cfg.serial == null then
|
||||||
control = "required";
|
{
|
||||||
cue = lib.mkDefault true;
|
u2f = {
|
||||||
};
|
enable = true;
|
||||||
|
inherit control;
|
||||||
|
cue = lib.mkDefault true;
|
||||||
|
};
|
||||||
|
|
||||||
services.udev.packages = [ pkgs.yubikey-personalization ];
|
services = {
|
||||||
security.pam.services = {
|
login.u2fAuth = lib.mkDefault true;
|
||||||
login.u2fAuth = true;
|
sudo.u2fAuth = lib.mkDefault true;
|
||||||
sudo.u2fAuth = true;
|
};
|
||||||
};
|
}
|
||||||
services.pcscd.enable = true;
|
else
|
||||||
|
{
|
||||||
|
yubico = {
|
||||||
|
enable = true;
|
||||||
|
inherit control;
|
||||||
|
mode = "challenge-response";
|
||||||
|
id = [ cfg.serial ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
services.udev.extraRules = lib.mkIf config.programs.xss-lock.enable ''
|
services.pcscd.enable = cfg.serial != null;
|
||||||
ACTION=="remove",\
|
|
||||||
ENV{DEVTYPE}=="usb_device",\
|
services.udev = {
|
||||||
ENV{PRODUCT}=="1050/402/543",\
|
packages = [ pkgs.yubikey-personalization ];
|
||||||
RUN+="${pkgs.systemd}/bin/loginctl lock-sessions"
|
extraRules = lib.mkIf cfg.unplug.enable ''
|
||||||
'';
|
ACTION=="remove",\
|
||||||
|
ENV{DEVTYPE}=="usb_device",\
|
||||||
|
ENV{PRODUCT}=="1050/${cfg.unplug.model}/543",\
|
||||||
|
RUN+="${cfg.unplug.command}"
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue