git.iko.soy/typeable/nixpkgs
on master help sign in
pam_p11: add
commitecafef0dd8f35aea4289648988122783b14cf5d4 authorSebastien Bourdeauducq <sb@m-labs.hk> dateSat 30 May 2020, 17:03 (6 years ago) parentf4a95e8
3 files changed+73
nixos/modules/security/pam.nix+47 pkgs/os-specific/linux/pam_p11/default.nix+24 pkgs/top-level/all-packages.nix+2
nixos/modules/security/pam.nix+47
@@ -36,6 +36,17 @@ let
3636 '';
3737 };
3838
39+ p11Auth = mkOption {
40+ default = config.security.pam.p11.enable;
41+ type = types.bool;
42+ description = ''
43+ If set, keys listed in
44+ <filename>~/.ssh/authorized_keys</filename> and
45+ <filename>~/.eid/authorized_certificates</filename>
46+ can be used to log in with the associated PKCS#11 tokens.
47+ '';
48+ };
49+
3950 u2fAuth = mkOption {
4051 default = config.security.pam.u2f.enable;
4152 type = types.bool;
@@ -352,6 +363,8 @@ let
352363 "auth sufficient ${pkgs.pam_ssh_agent_auth}/libexec/pam_ssh_agent_auth.so file=~/.ssh/authorized_keys:~/.ssh/authorized_keys2:/etc/ssh/authorized_keys.d/%u"}
353364 ${optionalString cfg.fprintAuth
354365 "auth sufficient ${pkgs.fprintd}/lib/security/pam_fprintd.so"}
366+ ${let p11 = config.security.pam.p11; in optionalString cfg.p11Auth
367+ "auth ${p11.control} ${pkgs.pam_p11}/lib/security/pam_p11.so ${pkgs.opensc}/lib/opensc-pkcs11.so"}
355368 ${let u2f = config.security.pam.u2f; in optionalString cfg.u2fAuth
356369 "auth ${u2f.control} ${pkgs.pam_u2f}/lib/security/pam_u2f.so ${optionalString u2f.debug "debug"} ${optionalString (u2f.authFile != null) "authfile=${u2f.authFile}"} ${optionalString u2f.interactive "interactive"} ${optionalString u2f.cue "cue"}"}
357370 ${optionalString cfg.usbAuth
@@ -566,6 +579,39 @@ in
566579
567580 security.pam.enableOTPW = mkEnableOption "the OTPW (one-time password) PAM module";
568581
582+ security.pam.p11 = {
583+ enable = mkOption {
584+ default = false;
585+ type = types.bool;
586+ description = ''
587+ Enables P11 PAM (<literal>pam_p11</literal>) module.
588+
589+ If set, users can log in with SSH keys and PKCS#11 tokens.
590+
591+ More information can be found <link
592+ xlink:href="https://github.com/OpenSC/pam_p11">here</link>.
593+ '';
594+ };
595+
596+ control = mkOption {
597+ default = "sufficient";
598+ type = types.enum [ "required" "requisite" "sufficient" "optional" ];
599+ description = ''
600+ This option sets pam "control".
601+ If you want to have multi factor authentication, use "required".
602+ If you want to use the PKCS#11 device instead of the regular password,
603+ use "sufficient".
604+
605+ Read
606+ <citerefentry>
607+ <refentrytitle>pam.conf</refentrytitle>
608+ <manvolnum>5</manvolnum>
609+ </citerefentry>
610+ for better understanding of this option.
611+ '';
612+ };
613+ };
614+
569615 security.pam.u2f = {
570616 enable = mkOption {
571617 default = false;
@@ -747,6 +793,7 @@ in
747793 ++ optionals config.krb5.enable [pam_krb5 pam_ccreds]
748794 ++ optionals config.security.pam.enableOTPW [ pkgs.otpw ]
749795 ++ optionals config.security.pam.oath.enable [ pkgs.oathToolkit ]
796+ ++ optionals config.security.pam.p11.enable [ pkgs.pam_p11 ]
750797 ++ optionals config.security.pam.u2f.enable [ pkgs.pam_u2f ];
751798
752799 boot.supportedFilesystems = optionals config.security.pam.enableEcryptfs [ "ecryptfs" ];
pkgs/os-specific/linux/pam_p11/default.nixnew file+24
@@ -0,0 +1,24 @@
1+{ stdenv, fetchFromGitHub, autoreconfHook, pkg-config, openssl, libp11, pam }:
2+
3+stdenv.mkDerivation rec {
4+ pname = "pam_p11";
5+ version = "0.3.1";
6+
7+ src = fetchFromGitHub {
8+ owner = "OpenSC";
9+ repo = "pam_p11";
10+ rev = "pam_p11-${version}";
11+ sha256 = "1caidy18rq5zk82d51x8vwidmkhwmanf3qm25x1yrdlbhxv6m7lk";
12+ };
13+
14+ nativeBuildInputs = [ autoreconfHook pkg-config ];
15+ buildInputs = [ pam openssl libp11 ];
16+
17+ meta = with stdenv.lib; {
18+ homepage = "https://github.com/OpenSC/pam_p11";
19+ description = "Authentication with PKCS#11 modules";
20+ license = licenses.lgpl21Plus;
21+ platforms = platforms.unix;
22+ maintainers = with maintainers; [ sb0 ];
23+ };
24+}
pkgs/top-level/all-packages.nix+2
@@ -17788,6 +17788,8 @@ in
1778817788
1778917789 pam_mount = callPackage ../os-specific/linux/pam_mount { };
1779017790
17791+ pam_p11 = callPackage ../os-specific/linux/pam_p11 { };
17792+
1779117793 pam_pgsql = callPackage ../os-specific/linux/pam_pgsql { };
1779217794
1779317795 pam_ssh_agent_auth = callPackage ../os-specific/linux/pam_ssh_agent_auth { };