Merge pull request #34728 from dpc/master

Add pam option to enable Google Authenticator

authored by Jörg Thalheim and committed by GitHub 79315b63 603952d8

+20 -1
+20 -1
nixos/modules/security/pam.nix
··· 46 46 ''; 47 47 }; 48 48 49 + googleAuthenticator = { 50 + enable = mkOption { 51 + default = false; 52 + type = types.bool; 53 + description = '' 54 + If set, users with enabled Google Authenticator (created 55 + <filename>~/.google_authenticator</filename>) will be required 56 + to provide Google Authenticator token to log in. 57 + ''; 58 + }; 59 + }; 60 + 49 61 usbAuth = mkOption { 50 62 default = config.security.pam.usb.enable; 51 63 type = types.bool; ··· 284 296 # prompts the user for password so we run it once with 'required' at an 285 297 # earlier point and it will run again with 'sufficient' further down. 286 298 # We use try_first_pass the second time to avoid prompting password twice 287 - (optionalString (cfg.unixAuth && (config.security.pam.enableEcryptfs || cfg.pamMount || cfg.enableKwallet || cfg.enableGnomeKeyring)) '' 299 + (optionalString (cfg.unixAuth && 300 + (config.security.pam.enableEcryptfs 301 + || cfg.pamMount 302 + || cfg.enableKwallet 303 + || cfg.enableGnomeKeyring 304 + || cfg.googleAuthenticator.enable)) '' 288 305 auth required pam_unix.so ${optionalString cfg.allowNullPassword "nullok"} likeauth 289 306 ${optionalString config.security.pam.enableEcryptfs 290 307 "auth optional ${pkgs.ecryptfs}/lib/security/pam_ecryptfs.so unwrap"} ··· 295 312 " kwalletd=${pkgs.libsForQt5.kwallet.bin}/bin/kwalletd5")} 296 313 ${optionalString cfg.enableGnomeKeyring 297 314 ("auth optional ${pkgs.gnome3.gnome_keyring}/lib/security/pam_gnome_keyring.so")} 315 + ${optionalString cfg.googleAuthenticator.enable 316 + "auth required ${pkgs.googleAuthenticator}/lib/security/pam_google_authenticator.so no_increment_hotp"} 298 317 '') + '' 299 318 ${optionalString cfg.unixAuth 300 319 "auth sufficient pam_unix.so ${optionalString cfg.allowNullPassword "nullok"} likeauth try_first_pass"}