mirror of
https://github.com/postgres/postgres.git
synced 2025-07-23 03:21:12 +03:00
Allow plaintext 'password' authentication when user has a SCRAM verifier.
Oversight in the main SCRAM patch.
This commit is contained in:
@ -283,7 +283,6 @@ plain_crypt_verify(const char *role, const char *shadow_pass,
|
||||
const char *client_pass,
|
||||
char **logdetail)
|
||||
{
|
||||
int retval;
|
||||
char crypt_client_pass[MD5_PASSWD_LEN + 1];
|
||||
|
||||
/*
|
||||
@ -293,6 +292,21 @@ plain_crypt_verify(const char *role, const char *shadow_pass,
|
||||
*/
|
||||
switch (get_password_type(shadow_pass))
|
||||
{
|
||||
case PASSWORD_TYPE_SCRAM:
|
||||
if (scram_verify_plain_password(role,
|
||||
client_pass,
|
||||
shadow_pass))
|
||||
{
|
||||
return STATUS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
*logdetail = psprintf(_("Password does not match for user \"%s\"."),
|
||||
role);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case PASSWORD_TYPE_MD5:
|
||||
if (!pg_md5_encrypt(client_pass,
|
||||
role,
|
||||
@ -307,30 +321,33 @@ plain_crypt_verify(const char *role, const char *shadow_pass,
|
||||
*/
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
client_pass = crypt_client_pass;
|
||||
if (strcmp(crypt_client_pass, shadow_pass) == 0)
|
||||
return STATUS_OK;
|
||||
else
|
||||
{
|
||||
*logdetail = psprintf(_("Password does not match for user \"%s\"."),
|
||||
role);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case PASSWORD_TYPE_PLAINTEXT:
|
||||
if (strcmp(client_pass, shadow_pass) == 0)
|
||||
return STATUS_OK;
|
||||
else
|
||||
{
|
||||
*logdetail = psprintf(_("Password does not match for user \"%s\"."),
|
||||
role);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
/*
|
||||
* This shouldn't happen. Plain "password" authentication should
|
||||
* be possible with any kind of stored password hash.
|
||||
*/
|
||||
*logdetail = psprintf(_("Password of user \"%s\" is in unrecognized format."),
|
||||
role);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
if (strcmp(client_pass, shadow_pass) == 0)
|
||||
retval = STATUS_OK;
|
||||
else
|
||||
{
|
||||
*logdetail = psprintf(_("Password does not match for user \"%s\"."),
|
||||
role);
|
||||
retval = STATUS_ERROR;
|
||||
}
|
||||
|
||||
return retval;
|
||||
/*
|
||||
* This shouldn't happen. Plain "password" authentication is possible
|
||||
* with any kind of stored password hash.
|
||||
*/
|
||||
*logdetail = psprintf(_("Password of user \"%s\" is in unrecognized format."),
|
||||
role);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
Reference in New Issue
Block a user