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

@ -138,6 +138,29 @@ static const char* admin_add_user(USERS** pusers,
return ADMIN_SUCCESS;
}
static const char* admin_alter_user(USERS** pusers,
const char* fname,
const char* uname,
const char* password)
{
if (*pusers == NULL)
{
*pusers = users_alloc();
}
if (!users_change_password(*pusers, uname, password))
{
return ADMIN_ERR_USERNOTFOUND;
}
if (!admin_dump_users(*pusers, fname))
{
return ADMIN_ERR_FILEOPEN;
}
return ADMIN_SUCCESS;
}
static const char* admin_remove_user(USERS* users, const char* fname, const char* uname)
{
if (!users_delete(users, uname))
@ -437,6 +460,19 @@ const char* admin_add_inet_user(const char* uname, const char* password, enum us
return admin_add_user(&inet_users, INET_USERS_FILE_NAME, uname, password, type);
}
/**
* Alter network user.
*
* @param uname The user to alter
* @param password The new password
*
* @return NULL on success or an error string on failure.
*/
const char* admin_alter_inet_user(const char* uname, const char* password)
{
return admin_alter_user(&inet_users, INET_USERS_FILE_NAME, uname, password);
}
/**
* Remove insecure remote (network) user
*