do not allow reset auth to new to be used along with add identified clauses

This commit is contained in:
Arthur Passos 2024-08-20 17:16:12 -03:00
parent f0223aedde
commit 4fd19c3ad9
3 changed files with 12 additions and 0 deletions

View File

@ -660,6 +660,11 @@ bool ParserCreateUserQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
}
if (reset_authentication_methods_to_new && !auth_data.empty())
{
throw Exception(ErrorCodes::BAD_ARGUMENTS, "RESET AUTHENTICATION METHODS TO NEW cannot be used along with [ADD] IDENTIFIED clauses");
}
if (!alter && !hosts)
{
String common_host_pattern;

View File

@ -55,6 +55,8 @@ RESET AUTHENTICATION METHODS TO NEW can only be used on alter statement
BAD_ARGUMENTS
ADD NOT IDENTIFIED should result in syntax error
SYNTAX_ERROR
RESET AUTHENTICATION METHODS TO NEW cannot be used along with [ADD] IDENTIFIED clauses
BAD_ARGUMENTS
localhost 9000 0 0 0
localhost 9000 0 0 0
Basic authentication after user creation
@ -130,3 +132,5 @@ RESET AUTHENTICATION METHODS TO NEW can only be used on alter statement
BAD_ARGUMENTS
ADD NOT IDENTIFIED should result in syntax error
SYNTAX_ERROR
RESET AUTHENTICATION METHODS TO NEW cannot be used along with [ADD] IDENTIFIED clauses
BAD_ARGUMENTS

View File

@ -152,6 +152,9 @@ function test
echo "ADD NOT IDENTIFIED should result in syntax error"
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} $1 ADD NOT IDENTIFIED" 2>&1 | grep -m1 -o "SYNTAX_ERROR"
echo "RESET AUTHENTICATION METHODS TO NEW cannot be used along with [ADD] IDENTIFIED clauses"
${CLICKHOUSE_CLIENT} --query "ALTER USER ${user} $1 IDENTIFIED WITH plaintext_password by '1' RESET AUTHENTICATION METHODS TO NEW" 2>&1 | grep -m1 -o "BAD_ARGUMENTS"
${CLICKHOUSE_CLIENT} --query "DROP USER IF EXISTS ${user}"
}