Adding protection for enabling MFA when MFA is not available.

This commit is contained in:
stephb9959
2022-05-05 09:25:32 -07:00
parent c19ce8a92c
commit afc8a59267
4 changed files with 29 additions and 1 deletions

2
build
View File

@@ -1 +1 @@
47
48

View File

@@ -6,6 +6,7 @@
#include "StorageService.h"
#include "framework/ow_constants.h"
#include "SMSSender.h"
#include "SMTPMailerService.h"
#include "ACLProcessor.h"
#include "AuthService.h"
#include "RESTAPI/RESTAPI_db_helpers.h"
@@ -252,6 +253,18 @@ namespace OpenWifi {
return BadRequest(RESTAPI::Errors::BadMFAMethod);
}
if( NewUser.userTypeProprietaryInfo.mfa.enabled &&
NewUser.userTypeProprietaryInfo.mfa.method == MFAMETHODS::SMS &&
!SMSSender()->Enabled()) {
return BadRequest(RESTAPI::Errors::SMSMFANotEnabled);
}
if( NewUser.userTypeProprietaryInfo.mfa.enabled &&
NewUser.userTypeProprietaryInfo.mfa.method == MFAMETHODS::EMAIL &&
!SMTPMailerService()->Enabled()) {
return BadRequest(RESTAPI::Errors::EMailMFANotEnabled);
}
bool ChangingMFA =
NewUser.userTypeProprietaryInfo.mfa.enabled && !Existing.userTypeProprietaryInfo.mfa.enabled;
Existing.userTypeProprietaryInfo.mfa.enabled = NewUser.userTypeProprietaryInfo.mfa.enabled;

View File

@@ -6,6 +6,7 @@
#include "StorageService.h"
#include "framework/ow_constants.h"
#include "SMSSender.h"
#include "SMTPMailerService.h"
#include "ACLProcessor.h"
#include "AuthService.h"
#include "RESTAPI/RESTAPI_db_helpers.h"
@@ -260,6 +261,18 @@ namespace OpenWifi {
return BadRequest(RESTAPI::Errors::BadMFAMethod);
}
if( NewUser.userTypeProprietaryInfo.mfa.enabled &&
NewUser.userTypeProprietaryInfo.mfa.method == MFAMETHODS::SMS &&
!SMSSender()->Enabled()) {
return BadRequest(RESTAPI::Errors::SMSMFANotEnabled);
}
if( NewUser.userTypeProprietaryInfo.mfa.enabled &&
NewUser.userTypeProprietaryInfo.mfa.method == MFAMETHODS::EMAIL &&
!SMTPMailerService()->Enabled()) {
return BadRequest(RESTAPI::Errors::EMailMFANotEnabled);
}
bool ChangingMFA =
NewUser.userTypeProprietaryInfo.mfa.enabled && !Existing.userTypeProprietaryInfo.mfa.enabled;
Existing.userTypeProprietaryInfo.mfa.enabled = NewUser.userTypeProprietaryInfo.mfa.enabled;

View File

@@ -102,6 +102,8 @@ namespace OpenWifi::RESTAPI::Errors {
static const std::string InvalidRegistrationOperatorId{"Invalid registration operator ID."};
static const std::string InvalidRegistrationOperatorName{"Invalid registration operator name."};
static const std::string RegistrationNameDuplicate{"Registration name must be unique."};
static const std::string SMSMFANotEnabled{"SMS is not enabled in the security service."};
static const std::string EMailMFANotEnabled{"email is not enabled in the security service."};
}
namespace OpenWifi::RESTAPI::Protocol {