#pragma once #include #include #include namespace DB { /** Represents authentication data in CREATE/ALTER USER query: * ... IDENTIFIED WITH sha256_password BY 'password' * * Can store password, hash and salt, LDAP server name, Kerberos Realm, or common names. * They are stored in children vector as ASTLiteral or ASTQueryParameter. * ASTAuthenticationData without a type represents authentication data with * the default password type that will be later inferred from the server parameters. */ class ASTAuthenticationData : public IAST { public: String getID(char) const override { return "AuthenticationData"; } ASTPtr clone() const override { auto clone = std::make_shared(*this); clone->cloneChildren(); return clone; } bool hasSecretParts() const override; std::optional getPassword() const; std::optional getSalt() const; std::optional ssl_cert_subject_type; /// CN or SubjectAltName /// If type is empty we use the default password type. /// AuthenticationType::NO_PASSWORD is specified explicitly. std::optional type; bool contains_password = false; bool contains_hash = false; ASTPtr valid_until; protected: void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override; }; }