Built-in Authentication
Apache Doris provides a built-in user authentication mechanism. Administrators create users, set passwords, and control the connection source through SQL commands. This document describes how a Doris user identity is composed, the available password policies, the IP matching priority, and common operational scenarios and troubleshooting methods.
Applicable Scenarios
| Scenario | Recommended Section |
|---|---|
| Create an account, drop an account, reset a password | Core Concepts, Common Operational Commands |
| Configure enterprise-grade password policies (expiration / history / strength / lockout) | Password Policies |
| Rotate an application password while clients migrate | Dual Passwords |
The same user name matches multiple user_identity values and login is rejected | User Identity Matching Priority |
| Block a specific IP from logging in (simulate a blacklist) | Simulating a Blacklist with a Whitelist |
Forgot the root password, or current_user() does not match user() | FAQ |
Core Concepts
User (user_identity)
In Doris, a user_identity uniquely identifies a user and consists of two parts:
user_name: the user name.host: the host address from which the client connects. It supports%for fuzzy matching.
If host is not specified, it defaults to '%', which means the user can connect to Doris from any host.
User Properties
User properties are attached directly to the user_name, not to the user_identity. That is, user@'192.%' and user@['domain'] share the same set of user properties. The properties belong to the user, not to user@'192.%' or user@['domain'].
User properties include, but are not limited to, the maximum number of user connections, load cluster configuration, and so on.
Built-in Users
Built-in users are users that Doris creates by default and that have certain privileges out of the box, including root and admin. Their initial passwords are empty. After the FE starts, you can change the password with the password modification command. Default users cannot be dropped.
| User | Allowed Login Source | Default Role |
|---|---|---|
root@'%' | Any node | operator |
admin@'%' | Any node | admin |
Password
The password is the credential used by a user to log in. It is set by the administrator when the user is created, and the user can also change it later.
Authentication Mechanism
Doris authentication consists of the following two steps:
- The client sends authentication information. The client packages the user information (user name, password, database, and so on) and sends it to the Doris server to prove its identity and request access to the database.
- The server verifies the identity. After Doris receives the authentication information, it verifies it. If the user name, password, and client IP are all correct and the user has access to the selected database, authentication succeeds and Doris maps the user to a system user identity. Otherwise, authentication fails and the corresponding error message is returned to the client.
Password Policies
Doris supports the following password policies to help administrators manage the password lifecycle and security.
| Policy | Purpose | Default Value |
|---|---|---|
PASSWORD_HISTORY | Forbid reusing the last N passwords | 0 (disabled) |
PASSWORD_EXPIRE | Set the password expiration time | NEVER (does not expire) |
FAILED_LOGIN_ATTEMPTS + PASSWORD_LOCK_TIME | Lock the account after consecutive failed logins | Disabled |
validate_password_policy | Validate password strength | NONE/0 (no validation) |
PASSWORD_HISTORY
Controls whether the current user is allowed to reuse previous passwords when resetting the password. For example, PASSWORD_HISTORY 10 forbids using any of the last 10 passwords as the new password. If set to PASSWORD_HISTORY DEFAULT, the value of the global variable password_history is used. 0 disables this feature, and the default is 0.
Examples:
- Set the global variable:
SET GLOBAL password_history = 10 - Set for a user:
ALTER USER user1@'ip' PASSWORD_HISTORY 10
PASSWORD_EXPIRE
Sets the expiration time of the current user's password. For example, PASSWORD_EXPIRE INTERVAL 10 DAY means the password expires in 10 days. PASSWORD_EXPIRE NEVER means the password does not expire. If set to PASSWORD_EXPIRE DEFAULT, the value of the global variable default_password_lifetime is used (in days). The default is NEVER (or 0), meaning the password does not expire.
Examples:
- Set the global variable:
SET GLOBAL default_password_lifetime = 1 - Set for a user:
ALTER USER user1@'ip' PASSWORD_EXPIRE INTERVAL 10 DAY
FAILED_LOGIN_ATTEMPTS and PASSWORD_LOCK_TIME
Locks the current user's account after n failed login attempts and sets the lockout duration. For example, FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY means the account is locked for one day after 3 failed login attempts. An administrator can manually unlock a locked account with the ALTER USER statement.
Example:
- Set for a user:
ALTER USER user1@'ip' FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY
Password Strength
This feature is controlled by the global variable validate_password_policy. The default is NONE/0, which means password strength is not checked. If set to STRONG/2, the password must contain at least 3 of the following 4 categories: uppercase letters, lowercase letters, digits, and special characters, and its length must be at least 8.
Example:
SET validate_password_policy = STRONG
Viewing Password Policies
After the policies above are set, you can view them with the following command:
SHOW PROC "/auth/'<user>'@'<host>'";
Note that the user and host parts must each be wrapped in single quotes. For example:
SHOW PROC "/auth/'root'@'%'";
SHOW PROC "/auth/'user1'@'127.0.0.1'";
Dual Passwords
Supported since 4.2.1. Built-in password authentication can keep one primary password and one retained secondary password for the same account. Use this overlap to migrate clients to a new password without rejecting clients that still use the previous one. A secondary password is absent by default and is created only with RETAIN CURRENT PASSWORD. These changes affect subsequent authentications and do not disconnect existing sessions.
Prerequisites
- Upgrade every FE to 4.2.1 or later before using these clauses.
- Execute the rotation as an administrator with global
GRANT_PRIVorADMIN_PRIV. RETAIN requires this privilege even on your own account; an ordinary self-service SET PASSWORD without RETAIN does not. - Use an account with a built-in, nonempty primary password. LDAP and authentication integrations manage their own credentials.
Rotate a Password
-
Create an example account, then set a new password while retaining its current one. For an existing account, run only the ALTER USER statement.
CREATE USER 'app_user'@'%' IDENTIFIED BY 'OldPwd_2026!';
ALTER USER 'app_user'@'%' IDENTIFIED BY 'NewPwd_2026!' RETAIN CURRENT PASSWORD;Both
OldPwd_2026!andNewPwd_2026!can authenticate. An equivalent retaining change isSET PASSWORD FOR 'app_user'@'%' = PASSWORD('NewPwd_2026!') RETAIN CURRENT PASSWORD; use it instead of the ALTER statement, not after it. -
Update every client to use
NewPwd_2026!. Check the account's retained-password state:SHOW GRANTS FOR 'app_user'@'%';The
Passwordcolumn showsYes (dual).SHOW ALL GRANTSandSHOW PROC '/auth'expose the same marker. Each FE'sdoris_fe_secondary_password_auth_totalmetric counts successful authentications using the secondary password, across all accounts, after account-policy checks; observe its increments rather than waiting for this cumulative counter to return to zero. -
After all clients have migrated, revoke the secondary password:
ALTER USER 'app_user'@'%' DISCARD OLD PASSWORD;Only
NewPwd_2026!can authenticate, and thePasswordcolumn returns toYes. Repeating DISCARD when no secondary exists has no effect.
Password Lifetime and Policy Rules
| Operation | Result |
|---|---|
| Nonempty new password with RETAIN | Previous primary becomes the only secondary; any earlier secondary is replaced. |
| Nonempty change without RETAIN | Existing secondary remains valid. Replacing the primary alone does not revoke it. |
| Empty new password | Both slots are cleared, even with RETAIN. |
| RETAIN with an empty current primary | Rejected. |
| DISCARD OLD PASSWORD | Only the secondary is removed. Password history and the password expiration clock are unchanged. |
Both passwords are subject to the account's lock and expiration policies. A retaining change is still a password change and follows password strength/history rules and updates the expiration clock. Binding, unbinding, or changing an authentication integration clears any retained secondary; RETAIN is rejected across these transitions. DISCARD is a standalone ALTER USER operation and cannot be combined with a password change, policy change, or comment.
Domain Accounts and Version Changes
For a domain account, DISCARD clears the persistent domain account first. Resolved-IP entries stop accepting their retained copy at the next domain-resolver refresh. The normal interval is 10 seconds, but this is not a strict revocation-time bound.
During a rolling upgrade, an older FE authenticates against the primary only and cannot parse the new clauses. Wait until every FE has been upgraded before starting dual-password rotation. Downgrading after using the feature loses the retained secondary; only the primary survives, and upgrading again does not restore the old secondary.
For the full statement reference, see ALTER USER and SET PASSWORD.
User Identity Matching Priority
A user_identity is composed of a user_name and a host, but when logging in the user only provides a user_name. Doris matches the corresponding host based on the client IP to decide which user_identity to use for login.
If only one user_identity matches the client IP, Doris uses that one. When multiple user_identity values match, Doris applies the following priority:
| Comparison Scenario | Priority |
|---|---|
| Specific IP vs domain | Specific IP takes priority over domain |
| Specific IP vs IP range | The more specific IP range wins (for example, 192.% over %) |
Example 1: IP Takes Priority Over Domain
CREATE USER user1@['domain1'] IDENTIFIED BY "12345";
CREATE USER user1@'ip1' IDENTIFIED BY "abcde";
Suppose domain1 resolves to two IPs: ip1 and ip2. Because IP takes priority over domain, when user user1 tries to log in to Doris from ip1 with the password '12345', the login is rejected (the correct password is 'abcde').
Example 2: More Specific IP Range Wins
CREATE USER user1@'%' IDENTIFIED BY "12345";
CREATE USER user1@'192.%' IDENTIFIED BY "abcde";
Because '192.%' takes priority over '%', when user user1 tries to log in to Doris from 192.168.1.1 with the password '12345', the login is rejected (the correct password is 'abcde').
Simulating a Blacklist with a Whitelist
Doris does not natively support blacklists, only whitelists. However, you can use the User Identity Matching Priority to simulate a blacklist.
For example, suppose a user named user@'192.%' has been created, allowing users from 192.* to log in. To block logins from 192.168.10.1, create another user cmy@'192.168.10.1' and set a new password. Because 192.168.10.1 has higher priority than 192.%, users from 192.168.10.1 can no longer log in with the old password.
Common Operational Commands
| Operation | Command |
|---|---|
| Create a user | CREATE USER |
| View user grants | SHOW ALL GRANTS |
| Modify a user | ALTER USER |
| Change a password | SET PASSWORD |
| Drop a user | DROP USER |
| Set user properties | SET PROPERTY |
| View user properties | SHOW PROPERTY |
FAQ
Q: How do I reset a forgotten password?
If you have forgotten the password and cannot log in to Doris, follow these steps to recover:
-
Add the following parameter to the FE config file:
skip_localhost_auth_check = true -
Restart the FE.
-
Log in to Doris on the FE host as the root user without a password.
-
After logging in, reset the password with the
SET PASSWORDcommand.
Q: Can other users reset the root user's password?
No. No user other than root can reset the root user's password.
Q: What is the difference between current_user() and user()?
You can run SELECT current_user() and SELECT user() to view current_user and user respectively:
current_user: the identity under which the current user passed authentication (theuser_identityused when the user was created).user: the actual user identity the user currently has, including the real client IP.
For example, suppose the user user1@'192.%' is created, and then a user user1 from 192.168.10.1 logs in to the system. In that case, current_user is user1@'192.%' and user is user1@'192.168.10.1'.
All privileges are granted to a specific current_user, and the real user holds all the privileges of that current_user.
Q: A user's login is rejected, but the password is confirmed to be correct. Why?
This usually means the User Identity Matching Priority rules took effect: the client IP matched a more specific user_identity, and the user should log in with the password that belongs to that user_identity. You can confirm the actual matched identity with the following command:
SELECT current_user();