git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/mosquitto: Add checkPasswords option

Related to https://github.com/NixOS/nixpkgs/issues/27130. Adds an option to NixOS configuration option to have Mosquitto use the password file that it generates. When this option is false the Mosquitto server will accept login attempts with any username and any password. This option defaults to false because this matches the behavior of the service prior to the introduction of this option. When the `services.mosquitto.checkPasswords` is true, the server will only accept valid usernames and passwords.

commit66b07e41e633bb6df1f1a57aa46856e7248da0da authorRichard Larocque <richard.larocque@gmail.com> dateSun 6 Aug 2017, 15:21 (9 years ago) parent638b671
1 file changed+14
nixos/modules/services/networking/mosquitto.nix+14
nixos/modules/services/networking/mosquitto.nix+14
@@ -12,6 +12,10 @@ let
1212 keyfile ${cfg.ssl.keyfile}
1313 '';
1414
15+ passwordConf = optionalString cfg.checkPasswords ''
16+ password_file ${cfg.dataDir}/passwd
17+ '';
18+
1519 mosquittoConf = pkgs.writeText "mosquitto.conf" ''
1620 pid_file /run/mosquitto/pid
1721 acl_file ${aclFile}
@@ -19,6 +23,7 @@ let
1923 allow_anonymous ${boolToString cfg.allowAnonymous}
2024 bind_address ${cfg.host}
2125 port ${toString cfg.port}
26+ ${passwordConf}
2227 ${listenerConf}
2328 ${cfg.extraConf}
2429 '';
@@ -153,6 +158,15 @@ in
153158 '';
154159 };
155160
161+ checkPasswords = mkOption {
162+ default = false;
163+ example = true;
164+ type = types.bool;
165+ description = ''
166+ Refuse connection when clients provide incorrect passwords.
167+ '';
168+ };
169+
156170 extraConf = mkOption {
157171 default = "";
158172 type = types.lines;