Built-in Authentication
Key Concepts
User
In Doris, a user_identity uniquely identifies a user. user_identity consists of two parts: user_name and host, where user_name is the username. host identifies the host address from which the user connects. The host part can use % for fuzzy matching. If host is not specified, it defaults to %, meaning the user can connect to Doris from any host.
User Attributes
User attributes are directly attached to user_name, not user_identity, meaning user@'192.%' and user@['domain'] share the same set of user attributes. These attributes belong to the user, not user@'192.%' or user@['domain'].
User attributes include, but are not limited to: maximum number of user connections, import cluster configuration, etc.
Built-in Users
Built-in users are users created by default in Doris and have certain permissions by default, including root and admin. Initial passwords are empty and can be changed after the frontend starts using password modification commands. Default users cannot be deleted.
root@'%': Root user, allowed to log in from any node, role is operator.admin@'%': Admin user, allowed to log in from any node, role is admin.
Password
Credentials for user login, set by the administrator when creating the user, can also be changed by the user after creation.
Password Policy
Doris supports the following password policies to help users manage passwords better.
PASSWORD_HISTORYWhether the current user is allowed to use historical passwords when resetting their password. For example,PASSWORD_HISTORY 10means that the past 10 passwords cannot be reused as the new password. If set toPASSWORD_HISTORY DEFAULT, the value of the global variablepassword_historywill be used. 0 means this feature is not enabled. The default is 0. Example:- Set global variable:
SET GLOBAL password_history = 10 - Set for user:
ALTER USER user1@'ip' PASSWORD_HISTORY 10
- Set global variable:
PASSWORD_EXPIRESet the password expiration time for the current user. For example,PASSWORD_EXPIRE INTERVAL 10 DAYmeans the password will expire in 10 days.PASSWORD_EXPIRE NEVERmeans the password will never expire. If set toPASSWORD_EXPIRE DEFAULT, the value of the global variabledefault_password_lifetimewill be used (in days). The default isNEVER(or 0), meaning the password will not expire. Example:- Set global variable:
SET GLOBAL default_password_lifetime = 1 - Set for user:
ALTER USER user1@'ip' PASSWORD_EXPIRE INTERVAL 10 DAY
- Set global variable:
FAILED_LOGIN_ATTEMPTSandPASSWORD_LOCK_TIMESet the number of incorrect password attempts before the account is locked and the lock time. For example,FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAYmeans the account will be locked for one day after 3 incorrect login attempts. Administrators can unlock locked accounts using theALTER USERstatement. Example:- Set for user:
ALTER USER user1@'ip' FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY
- Set for user:
- Password Strength
Controlled by the global variable
validate_password_policy. The default isNONE/0, meaning no password strength check. If set toSTRONG/2, the password must contain at least 3 of the following: "uppercase letters", "lowercase letters", "numbers", and "special characters", and the length must be at least 8. Example:SET validate_password_policy=STRONG
Authentication Mechanism
- Client Authentication Information Sending: The client packages user information (such as username, password, database, etc.) and sends it to the Doris server. This information is used to prove the client's identity and request access to the database.
- Server Authentication: After receiving the client's authentication information, Doris verifies it. If the username, password, and client IP are correct, and the user has permission to access the selected database, authentication is successful, and Doris maps the user entity to the system's user identity. Otherwise, authentication fails, and an error message is returned to the client.
Whitelist and Blacklist
Doris itself does not support a blacklist, only a whitelist function, but we can simulate a blacklist in some ways. Suppose a user named user@'192.%' is created, allowing users from 192.* to log in. If you want to prohibit users from 192.168.10.1 from logging in, you can create another user cmy@'192.168.10.1' and set a new password. Since 192.168.10.1 has a higher priority than 192.%, users from 192.168.10.1 will no longer be able to log in using the old password.
Related Commands
- Create User: CREATE USER
- View User: SHOW ALL GRANTS
- Modify User: ALTER USER
- Change Password: SET PASSWORD
- Delete User: DROP USER
- Set User Attributes: SET PROPERTY
- View User Attributes: SHOW PROPERTY
Other Explanations
-
User Identity Priority Selection Issue During Login
As introduced above,
user_identityconsists ofuser_nameandhost, but when logging in, the user only needs to enteruser_name, so Doris determines based on the client's IP whichuser_identityto use for login.If only one
user_identitycan be matched based on the client's IP, it will be used for login without any issues. However, if multipleuser_identitycan be matched, there will be a priority issue.-
Priority between domain name and IP: Suppose the following users are created:
CREATE USER user1@['domain1'] IDENTIFIED BY "12345";
CREATE USER user1@'ip1'IDENTIFIED BY "abcde";domain1is resolved to two IPs:ip1andip2.In terms of priority, IP takes precedence over domain name. Therefore, when user
user1attempts to log in to Doris fromip1using password'12345', the login will be rejected. -
Priority between specific IP and range IP: Suppose the following users are created:
CREATE USER user1@'%' IDENTIFIED BY "12345";
CREATE USER user1@'192.%' IDENTIFIED BY "abcde";In terms of priority,
'192.%'takes precedence over'%'. Therefore, when useruser1attempts to log in to Doris from192.168.1.1using password'12345', the login will be rejected.
-
-
Forgotten Password
If you forget your password and cannot log in to Doris, you can add the
skip_localhost_auth_check=trueparameter to the FE's configuration file and restart the FE. This will allow you to log in to Doris from the FE machine without a password using therootuser.After logging in, you can use the
SET PASSWORDcommand to reset your password. -
Any user cannot reset the password of the
rootuser, except for therootuser itself. -
current_user()anduser()Users can use
SELECT current_user()andSELECT user()to viewcurrent_useranduser, respectively.current_userindicates the identity used by the current user to pass the authentication system, whileuseris the actual User Identity of the current user.For example:
Suppose
user1@'192.%'is created, and then a user nameduser1logs in to the system from192.168.10.1. At this time,current_userisuser1@'192.%', anduserisuser1@'192.168.10.1'.All permissions are granted to a specific
current_user, and the actual user has all the permissions of the correspondingcurrent_user.