-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add default password type #44674
Add default password type #44674
Conversation
99a0088
to
ccfece0
Compare
6a8c63f
to
cc0f758
Compare
cc0f758
to
3a20fbd
Compare
So let's keep the plaintext password in a |
d7f33e3
to
fe84006
Compare
fe84006
to
dbc620f
Compare
} | ||
namespace | ||
{ | ||
AuthenticationData makeAuthenticationData(const ASTAuthenticationData & query, ContextPtr context, bool check_password_rules) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially, I added functions makeAuthenticationData()
and makeASTAuthenticationData()
as methods to ASTAuthenticationData, but adding Context to clickhouse_parsers breaks the standalone keeper build, so I moved them to Interpreters.
Any suggestions on where to better put them are welcome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move that transformation function to Access/AuthenticationData.h/cpp?
We can make it a member function of AuthenticationData, kind of AuthenticationData::fromAST()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like a good idea, but I'm afraid that it will run into the same problem, clickhouse_common_access
is linked to clickhouse_parsers
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AuthenticationData.cpp
was in clickhouse_common_access
only because it was used in ASTCreateUser
. Now that's not the case anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But AuthenticationData.h/cpp
is used both in ASTAuthenticationData
and in ParseCreateUserQuery
because of the AuthenticationType
. Maybe I'm missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do something like this:
static AuthenticationData::fromAST(
ASTPtr query,
const ASTs & prepared_arguments,
std::optional<AuthenticationType> default_type
//, std::optional<int> bcrypt_param - in the future
)
InterpreterCreateUserQuery::execute():
...
std::optional<AuthenticationData> auth_data;
if (query.auth_data)
{
if (!query.attach)
{
auto password = auth_data->getPassword();
if (password)
global_context->getAccessControl().checkPasswordComplexityRules(*password);
}
AuthenticationType default_type = access_control.getDefaultPasswordType();
ASTs args(args_size);
for (size_t i = 0; i < args_size; ++i)
args[i] = evaluateConstantExpressionAsLiteral(query.children[i], context);
auth_data = AuthenticationData::fromAST(query, args, default_type);
}
...
Is it better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But
AuthenticationData.h/cpp
is used both inASTAuthenticationData
and inParseCreateUserQuery
because of theAuthenticationType
.
We can keep the AuthenticationType
enum in the folder src/Access/Common
and move AuthenticationData
to src/Access
.
f7b9284
to
08bf90d
Compare
08bf90d
to
0621222
Compare
src/Interpreters/Access/InterpreterShowCreateAccessEntityQuery.cpp
Outdated
Show resolved
Hide resolved
return ptr; | ||
auto clone = std::make_shared<ASTSubquery>(*this); | ||
clone->cloneChildren(); | ||
return clone; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related, just a small improvement
5c15e4f
to
b599d0b
Compare
} | ||
|
||
|
||
AuthenticationData AuthenticationData::fromAST(const ASTAuthenticationData & query, ContextPtr context, bool check_password_rules) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check password complexity rules in the InterpreterCreateQuery or is here ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both places seem ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to check them in the InterpreterCreateQuery
to make the conversion function more simple, but that's not very important.
Test failures are unrelated. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Password type in queries like
CREATE USER u IDENTIFIED BY 'p'
will be automatically set according to the settingdefault_password_type
in theconfig.xml
on the server. Closes #42915Query parameters can now also be used to specify passwords, for example:
CREATE USER u IDENTIFIED BY {password:String}