MXS-2574: Add PATCH for /users/inet endpoint

The alteration of user passwords is now done inside MaxScale. This
prevents the possibility of a user locking themselves out.
This commit is contained in:
Markus Mäkelä
2019-06-24 14:44:11 +03:00
parent 77671a2393
commit aac0ecc373
9 changed files with 115 additions and 13 deletions

View File

@ -2875,6 +2875,31 @@ bool runtime_remove_user(const char* id, enum user_type type)
return rval;
}
bool runtime_alter_user(const std::string& user, const std::string& type, json_t* json)
{
bool rval = false;
const char* password = json_string_value(mxs_json_pointer(json, MXS_JSON_PTR_PASSWORD));
if (!password)
{
config_runtime_error("No password provided");
}
else if (type != CN_INET)
{
config_runtime_error("Users of type '%s' cannot be altered", type.c_str());
}
else if (const char* err = admin_alter_inet_user(user.c_str(), password))
{
config_runtime_error("%s", err);
}
else
{
rval = true;
}
return rval;
}
bool validate_maxscale_json(json_t* json)
{
bool rval = false;