summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeon Schuermann <leon.git@is.currently.online>2018-01-15 14:34:58 +0700
committerLeon Schuermann <leon.git@is.currently.online>2018-01-15 14:34:58 +0700
commite45a06ebd1d761ccd48b6279c7ebb4429b17a6aa (patch)
treee2c9c9e7ce97faea019c97c7b0b3b742f7aa3540
parent940d1a99f9f6f83a75f1d7ceb9e7d7f0d69610ee (diff)
downloadnixpkgs-e45a06ebd1d761ccd48b6279c7ebb4429b17a6aa.tar
nixpkgs-e45a06ebd1d761ccd48b6279c7ebb4429b17a6aa.tar.gz
nixpkgs-e45a06ebd1d761ccd48b6279c7ebb4429b17a6aa.tar.bz2
nixpkgs-e45a06ebd1d761ccd48b6279c7ebb4429b17a6aa.tar.lz
nixpkgs-e45a06ebd1d761ccd48b6279c7ebb4429b17a6aa.tar.xz
nixpkgs-e45a06ebd1d761ccd48b6279c7ebb4429b17a6aa.tar.zst
nixpkgs-e45a06ebd1d761ccd48b6279c7ebb4429b17a6aa.zip
openvpn: add option to store credentials
-rw-r--r--nixos/modules/services/networking/openvpn.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/openvpn.nix b/nixos/modules/services/networking/openvpn.nix
index 3fbf5a9f022..8a059f60954 100644
--- a/nixos/modules/services/networking/openvpn.nix
+++ b/nixos/modules/services/networking/openvpn.nix
@@ -50,6 +50,11 @@ let
               "up ${pkgs.writeScript "openvpn-${name}-up" upScript}"}
           ${optionalString (cfg.down != "" || cfg.updateResolvConf)
               "down ${pkgs.writeScript "openvpn-${name}-down" downScript}"}
+          ${optionalString (cfg.authUserPass != null)
+              "auth-user-pass ${pkgs.writeText "openvpn-credentials-${name}" ''
+                ${cfg.authUserPass.username}
+                ${cfg.authUserPass.password}
+              ''}"}
         '';
 
     in {
@@ -161,6 +166,27 @@ in
             '';
           };
 
+          authUserPass = mkOption {
+            default = null;
+            description = ''
+              This option can be used to store the username / password credentials
+              with the "auth-user-pass" authentication method.
+            '';
+            type = types.nullOr (types.submodule {
+
+              options = {
+                username = mkOption {
+                  description = "The username to store inside the credentials file.";
+                  type = types.string;
+                };
+
+                password = mkOption {
+                  description = "The password to store inside the credentials file.";
+                  type = types.string;
+                };
+              };
+            });
+          };
         };
 
       });