make sure reset authentication methods can only be used on alter queries

This commit is contained in:
Arthur Passos 2024-08-14 12:44:43 -03:00
parent 026fa0a7fd
commit 3247f3ad08
3 changed files with 10 additions and 0 deletions

View File

@ -561,6 +561,11 @@ bool ParserCreateUserQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
if (!reset_authentication_methods_to_new.has_value())
{
reset_authentication_methods_to_new = parseResetAuthenticationMethods(pos, expected);
if (reset_authentication_methods_to_new.value() && !alter)
{
throw Exception(ErrorCodes::BAD_ARGUMENTS, "RESET AUTHENTICATION METHODS TO NEW can only be used on ALTER statement");
}
}
if (!valid_until)

View File

@ -51,3 +51,5 @@ Trailing comma should result in syntax error
SYNTAX_ERROR
First auth method can't specify type if WITH keyword is not present
SYNTAX_ERROR
RESET AUTHENTICATION METHODS TO NEW can only be used on alter statement
BAD_ARGUMENTS

View File

@ -144,4 +144,7 @@ ${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} ADD IDENTIFIED WITH plaintext_p
echo "First auth method can't specify type if WITH keyword is not present"
${CLICKHOUSE_CLIENT} --query "CREATE USER ${user} IDENTIFIED plaintext_password by '1'" 2>&1 | grep -m1 -o "SYNTAX_ERROR"
echo "RESET AUTHENTICATION METHODS TO NEW can only be used on alter statement"
${CLICKHOUSE_CLIENT} --query "CREATE USER ${user} RESET AUTHENTICATION METHODS TO NEW" 2>&1 | grep -m1 -o "BAD_ARGUMENTS"
${CLICKHOUSE_CLIENT} --query "DROP USER IF EXISTS ${user}"