bool locked = false;
if (isHashingAvailable()) {
- d_hashed = true;
-
if (!isPasswordHashed(password)) {
d_credentials = hashPassword(password);
locked = true;
}
else {
+ d_wasHashed = true;
d_credentials = std::move(password);
}
}
bool CredentialsHolder::matches(const std::string& password) const
{
- if (d_hashed) {
+ if (isHashingAvailable()) {
return verifyPassword(d_credentials, password);
}
else {
CredentialsHolder& operator=(const CredentialsHolder&) = delete;
bool matches(const std::string& password) const;
- bool isHashed() const
+ /* whether it was constructed from a hashed and salted string */
+ bool wasHashed() const
{
- return d_hashed;
+ return d_wasHashed;
}
static bool isHashingAvailable();
std::string d_credentials;
uint32_t d_fallbackHashPerturb;
uint32_t d_fallbackHash{0};
- bool d_hashed{false};
+ /* whether it was constructed from a hashed and salted string */
+ bool d_wasHashed{false};
};
auto launch=[sock, local, password, apiKey, customHeaders, acl]() {
if (password) {
auto holder = make_unique<CredentialsHolder>(std::string(*password));
- if (!holder->isHashed() && holder->isHashingAvailable()) {
+ if (!holder->wasHashed() && holder->isHashingAvailable()) {
warnlog("Passing a plain-text password to 'webserver()' is deprecated, please use 'setWebserverConfig()' instead.");
}
if (vars->count("password")) {
std::string password = boost::get<std::string>(vars->at("password"));
auto holder = make_unique<CredentialsHolder>(std::move(password));
- if (!holder->isHashed() && holder->isHashingAvailable()) {
+ if (!holder->wasHashed() && holder->isHashingAvailable()) {
warnlog("Passing a plain-text password via the 'password' parameter to 'setWebserverConfig()' is deprecated, please generate a hashed one using 'hashPassword()' instead.");
}
if (vars->count("apiKey")) {
std::string apiKey = boost::get<std::string>(vars->at("apiKey"));
auto holder = make_unique<CredentialsHolder>(std::move(apiKey));
- if (!holder->isHashed() && holder->isHashingAvailable()) {
+ if (!holder->wasHashed() && holder->isHashingAvailable()) {
warnlog("Passing a plain-text API key via the 'apiKey' parameter to 'setWebserverConfig()' is deprecated, please generate a hashed one using 'hashPassword()' instead.");
}