Commit 6075860a9793299be3d89942a7d139f9e2d74c13
1 parent
e8e10352
Better handling of the allow_anonymous setting
Showing
3 changed files
with
8 additions
and
2 deletions
authplugin.cpp
| ... | ... | @@ -454,7 +454,7 @@ AuthResult Authentication::aclCheckFromMosquittoAclFile(const std::string &clien |
| 454 | 454 | |
| 455 | 455 | AuthResult Authentication::unPwdCheckFromMosquittoPasswordFile(const std::string &username, const std::string &password) |
| 456 | 456 | { |
| 457 | - if (this->mosquittoPasswordFile.empty()) | |
| 457 | + if (this->mosquittoPasswordFile.empty() && settings.allowAnonymous) | |
| 458 | 458 | return AuthResult::success; |
| 459 | 459 | |
| 460 | 460 | if (!this->mosquittoPasswordEntries) | ... | ... |
mainapp.cpp
mqttpacket.cpp
| ... | ... | @@ -349,7 +349,11 @@ void MqttPacket::handleConnect() |
| 349 | 349 | bool accessGranted = false; |
| 350 | 350 | std::string denyLogMsg; |
| 351 | 351 | |
| 352 | - if (!settings.allowUnsafeUsernameChars && containsDangerousCharacters(username)) | |
| 352 | + if (!user_name_flag && settings.allowAnonymous) | |
| 353 | + { | |
| 354 | + accessGranted = true; | |
| 355 | + } | |
| 356 | + else if (!settings.allowUnsafeUsernameChars && containsDangerousCharacters(username)) | |
| 353 | 357 | { |
| 354 | 358 | denyLogMsg = formatString("Username '%s' has + or # in the id and 'allow_unsafe_username_chars' is false.", username.c_str()); |
| 355 | 359 | sender->setDisconnectReason("Invalid username character"); | ... | ... |