You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 328f500
Browse filesBrowse the repository at this point in the historyBrowse files
[feat](auth) Support MySQL-compatible dual password (RETAIN CURRENT PASSWORD / DISCARD OLD PASSWORD)
Add MySQL 8.0-compatible dual password support so a password can be
rotated online without breaking consumers that still hold the previous
one, on both ALTER USER and SET PASSWORD:
ALTER USER u IDENTIFIED BY 'new' RETAIN CURRENT PASSWORD;
ALTER USER u IDENTIFIED BY 'new'; -- secondary password unchanged
ALTER USER u DISCARD OLD PASSWORD; -- discard the retained password
SET PASSWORD = PASSWORD('new') RETAIN CURRENT PASSWORD;
Without an overlap window, every password change is a hard cutover: all
clients (BI tools, service accounts, AI/MCP consumers) must switch at the
same instant or fail to authenticate. The common workaround - two
alternating accounts - fragments audit attribution across two usernames.
MySQL solved this with dual passwords (WL#11544).
Semantics mirror the MySQL 8.0 manual:
- RETAIN CURRENT PASSWORD saves the current primary as the secondary
password; both authenticate. Exactly one secondary per user: the next
RETAIN replaces it.
- Changing the password WITHOUT the clause leaves an existing secondary
password unchanged.
- An empty new password empties the secondary as well, even with RETAIN.
- RETAIN on an account with an empty primary fails.
- DISCARD OLD PASSWORD (ALTER USER only, matching MySQL) drops the
secondary if one exists; combining it with a password change is rejected.
Privileges (revised per review): the dual password clauses are PRIVILEGED
even on one's own account. MySQL requires APPLICATION_PASSWORD_ADMIN for
RETAIN CURRENT PASSWORD / DISCARD OLD PASSWORD on one's own account,
precisely because otherwise anyone who briefly holds a password could park
their own in the secondary slot as a persistent, invisible credential.
Doris has no dynamic-privilege framework, so the clauses require the GRANT
tier (the same tier that already gates ALTER USER on other accounts):
- plain self-service SET PASSWORD stays unprivileged (unchanged);
- SET PASSWORD ... RETAIN CURRENT PASSWORD requires GRANT even on self;
- ALTER USER paths were already GRANT-gated by AlterUserInfo.validate().
A finer-grained APPLICATION_PASSWORD_ADMIN-style privilege (so that
low-privilege service accounts can self-rotate with an overlap window
without holding GRANT) is left as a follow-up.
Design:
- Password gains a nullable secondary slot (GSON field "pwd2"): absent
in images/journals written before this change, ignored by binaries
without it - tolerant in both directions, no meta version bump.
- Authentication tries the primary, then the secondary, against ONE
snapshot of the Password object, in one shared helper behind both
existing check paths (checkPasswordInternal and
checkPasswordInternalForUser), so every protocol lane (MySQL scramble,
cleartext/LDAP fallback, Arrow Flight, HTTP, stream load) behaves
identically. Failed-login policy fires only when both miss.
- Password changes swap in a fully-built Password object as a single
reference assignment (primary + carried secondary together), so there
is no window where the new primary is visible without the retained
secondary - the exact window a zero-downtime rotation must not have.
- The domain resolver clones BOTH password slots when materializing
resolved-IP users, so a resolver refresh after a rotation with RETAIN
does not evict the retained password.
- Replay: the retain flag rides PrivInfo on the existing OP_SET_PASSWORD
journal op. DISCARD OLD PASSWORD also rides OP_SET_PASSWORD (a discard
flag in PrivInfo, with passwd = the account's unchanged primary), NOT a
new operation value on OP_ALTER_USER: an older FE deserializes an
unknown AlterUserOpType as null and fails replay, whereas it replays
the PrivInfo form as a plain set-password to the value the account
already holds - a harmless no-op. Downgrade after first use is
therefore safe. For correct DISCARD semantics across a mixed-version
cluster, run all FEs on this version before first using the new
clauses (an old-binary follower applies the discard as a no-op until
it loads new state).
- Observability: authenticating with the retained password logs an INFO
line and increments fe metric secondary_password_auth_total, so
operators can verify all consumers converged on the new password
before rotating again (MySQL itself offers no such signal). The
log/metric fire only after account lock/expiration policy passes, so
a rejected login never counts as a successful secondary auth.
- Grammar: RETAIN/CURRENT/PASSWORD tokens existed; DISCARD and OLD are
added as nonReserved keywords (still valid as identifiers).
Deliberate differences from MySQL (noted for review):
- Privileges: Doris has no dynamic privileges, so the clauses use the
GRANT tier instead of a dedicated APPLICATION_PASSWORD_ADMIN (see
above; finer-grained privilege left as a follow-up).
- No per-user authentication plugins in Doris, so MySQL's
plugin-change-discards-secondary rule has no analog.
Out of scope: introspection of whether a user currently holds a retained
password (fe.audit.log keeps the RETAIN clause; a per-account indicator
is a natural follow-up alongside the finer-grained privilege).
### What problem does this PR solve?
Related PR: #67527, #67396
Problem Summary: #67527 added seven JUnit 4 `Assert` calls to
`ConfigTest` after #67396 migrated the class to JUnit 5, causing
`fe-common:testCompile` to fail with `cannot find symbol: Assert`. Use
the existing JUnit 5 `Assertions` import. Also migrate the scheduler
test introduced by the same PR to JUnit 5 assertions and lifecycle
annotations, consistent with the FE test migration.
### Release note
None
### Check List (For Author)
- Test: `./run-fe-ut.sh --run
org.apache.doris.common.ConfigTest,org.apache.doris.cloud.CacheHotspotManagerSchedulerTest`
completed with BUILD SUCCESS: ConfigTest 10/10 and
CacheHotspotManagerSchedulerTest 4/4 passed, with no failures, errors,
or skipped tests. Checkstyle passed for fe-common and fe-core with zero
violations; `git diff --check` passed.
- Behavior changed: No
- Does this need documentation: No
Rebased onto current master: the password change paths now carry both the retained-secondary flag and the
authentication-integration binding (setPasswordInternal / alterUserInternal take both), the domain resolver
materializes resolved-IP users with both password slots, and a bound account shows "No" in the password column.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Raghvendra Singh <[email protected]>
0 commit comments