git.iko.soy/typeable/nixpkgs
on master help sign in
add support for pam_u2f to nixos pam module

This adds support for authenticating using a U2F device such as a yubikey neo.

commit22167289794c080c50f092274de808543c7978c4 authorPhilip Potter <philip.g.potter@gmail.com> dateSun 3 May 2015, 15:29 (12 years ago) parent0f8203d
6 files changed+68−1
lib/maintainers.nix+1 nixos/modules/security/pam.nix+20 pkgs/development/libraries/libu2f-host/default.nix+1−1 pkgs/development/libraries/libu2f-server/default.nix+20 pkgs/os-specific/linux/pam_u2f/default.nix+22 pkgs/top-level/all-packages.nix+4
lib/maintainers.nix+1
@@ -153,6 +153,7 @@
153153 pakhfn = "Fedor Pakhomov <pakhfn@gmail.com>";
154154 pashev = "Igor Pashev <pashev.igor@gmail.com>";
155155 phausmann = "Philipp Hausmann <nix@314.ch>";
156+ philandstuff = "Philip Potter <philip.g.potter@gmail.com>";
156157 phreedom = "Evgeny Egorochkin <phreedom@yandex.ru>";
157158 pierron = "Nicolas B. Pierron <nixos@nbp.name>";
158159 piotr = "Piotr Pietraszkiewicz <ppietrasa@gmail.com>";
nixos/modules/security/pam.nix+20
@@ -36,6 +36,16 @@ let
3636 '';
3737 };
3838
39+ u2fAuth = mkOption {
40+ default = config.security.pam.enableU2F;
41+ type = types.bool;
42+ description = ''
43+ If set, users listed in
44+ <filename>~/.yubico/u2f_keys</filename> are able to log in
45+ with the associated U2F key.
46+ '';
47+ };
48+
3949 usbAuth = mkOption {
4050 default = config.security.pam.usb.enable;
4151 type = types.bool;
@@ -209,6 +219,8 @@ let
209219 "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"}
210220 ${optionalString cfg.fprintAuth
211221 "auth sufficient ${pkgs.fprintd}/lib/security/pam_fprintd.so"}
222+ ${optionalString cfg.u2fAuth
223+ "auth sufficient ${pkgs.pam_u2f}/lib/security/pam_u2f.so"}
212224 ${optionalString cfg.usbAuth
213225 "auth sufficient ${pkgs.pam_usb}/lib/security/pam_usb.so"}
214226 ${optionalString cfg.unixAuth
@@ -364,6 +376,13 @@ in
364376 '';
365377 };
366378
379+ security.pam.enableU2F = mkOption {
380+ default = false;
381+ description = ''
382+ Enable the U2F PAM module.
383+ '';
384+ };
385+
367386 security.pam.enableEcryptfs = mkOption {
368387 default = false;
369388 description = ''
@@ -392,6 +411,7 @@ in
392411 ++ optionals config.krb5.enable [pam_krb5 pam_ccreds]
393412 ++ optionals config.security.pam.enableOTPW [ pkgs.otpw ]
394413 ++ optionals config.security.pam.enableOATH [ pkgs.oathToolkit ]
414+ ++ optionals config.security.pam.enableU2F [ pkgs.pam_u2f ]
395415 ++ optionals config.security.pam.enableEcryptfs [ pkgs.ecryptfs ];
396416
397417 security.setuidPrograms =
pkgs/development/libraries/libu2f-host/default.nix+1−1
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
1212
1313 meta = with stdenv.lib; {
1414 homepage = https://developers.yubico.com/libu2f-host;
15− description = "a C library and command-line tool thati mplements the host-side of the U2F protocol";
15+ description = "A C library and command-line tool thati mplements the host-side of the U2F protocol";
1616 license = licenses.bsd2;
1717 platforms = platforms.unix;
1818 maintainers = with maintainers; [ wkennington ];
pkgs/development/libraries/libu2f-server/default.nixnew file+20
@@ -0,0 +1,20 @@
1+{ stdenv, fetchurl, pkgconfig, json_c, hidapi, openssl, check }:
2+
3+stdenv.mkDerivation rec {
4+ name = "libu2f-server-0.0.0";
5+
6+ src = fetchurl {
7+ url = "https://developers.yubico.com/libu2f-server/Releases/libu2f-server-0.0.0.tar.xz";
8+ sha256 = "1vdl3qavzfpi6p6h48zw17md9wykfzpay5c4l1c08id46m560wp0";
9+ };
10+
11+ buildInputs = [ pkgconfig json_c hidapi openssl check ];
12+
13+ meta = with stdenv.lib; {
14+ homepage = https://developers.yubico.com/libu2f-server/;
15+ description = "A C library that implements the server-side of the U2F protocol";
16+ license = licenses.bsd2;
17+ platforms = platforms.unix;
18+ maintainers = with maintainers; [ philandstuff ];
19+ };
20+}
pkgs/os-specific/linux/pam_u2f/default.nixnew file+22
@@ -0,0 +1,22 @@
1+{ pkgs, fetchurl, stdenv }:
2+stdenv.mkDerivation rec {
3+ name = "pam_u2f-${version}";
4+ version = "0.0.1";
5+ src = fetchurl {
6+ url = "https://developers.yubico.com/pam-u2f/Releases/${name}.tar.gz";
7+ sha256 = "0p1wia4nfw5h0pmy1lcgwsbrlm7z39v1n37692lgqfzyg1kmpv7l";
8+ };
9+ buildInputs = with pkgs; [ asciidoc autoconf automake docbook_xml_dtd_45 libtool libu2f-host libu2f-server libxml2 libxslt pkgconfig pam ];
10+
11+ installFlags = [
12+ "PAMDIR=$(out)/lib/security"
13+ ];
14+
15+ meta = with stdenv.lib; {
16+ homepage = https://developers.yubico.com/pam-u2f/;
17+ description = "A PAM module for allowing authentication with a U2F device";
18+ license = licenses.bsd2;
19+ platforms = platforms.unix;
20+ maintainers = with maintainers; [ philandstuff ];
21+ };
22+}
pkgs/top-level/all-packages.nix+4
@@ -6920,6 +6920,8 @@ let
69206920
69216921 libu2f-host = callPackage ../development/libraries/libu2f-host { };
69226922
6923+ libu2f-server = callPackage ../development/libraries/libu2f-server { };
6924+
69236925 libunistring = callPackage ../development/libraries/libunistring { };
69246926
69256927 libupnp = callPackage ../development/libraries/pupnp { };
@@ -9573,6 +9575,8 @@ let
95739575
95749576 pam_ssh_agent_auth = callPackage ../os-specific/linux/pam_ssh_agent_auth { };
95759577
9578+ pam_u2f = callPackage ../os-specific/linux/pam_u2f { };
9579+
95769580 pam_usb = callPackage ../os-specific/linux/pam_usb { };
95779581
95789582 paxctl = callPackage ../os-specific/linux/paxctl { };