Repository navigation
[feature](auth) SU ... WITH ROLES: proxy authentication with mandatory role narrowing, gated by PROXY_PRIV - #67672
raghav-reglobe wants to merge 30 commits into
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
Regression run, for the record: built FE + BE from this branch (aarch64, on top of current master), stood up a single-node cluster, and ran The six refusals the suite asserts on all fired with the expected messages: the global-only FE unit tests on current master: 70/70 across the SU classes plus |
700fb3c to
4d25532
Compare
4d25532 to
61c5b8e
Compare
|
Rebased onto current master (28577df). The session-layer refactors (#67883, #67900) removed the block next to our forwarded-narrowing hook in One new commit on top. The authorization plugin SPI (#66770) resolves every privilege check through Gate on this head, built from the branch on top of current master: FE build and checkstyle clean; the SU suites plus If you would rather not carry an API major bump inside this PR, the alternatives are a dedicated Ranger access type for PROXY or folding it under an existing action. Happy to go either way. |
`SU 'user'[@'host'] WITH ROLES ('r1'[, ...]) [WORKLOAD GROUP 'wg']` switches the
authenticated session to another user with a mandatory role list -- MySQL's
proxy-user model, narrowed. A middle tier (an AI or BI gateway, an MCP server)
authenticates once as itself and then runs each end-user session as that person,
restricted to an explicit subset of the person's roles, so Doris -- not the
gateway -- enforces the table privileges, row policies and workload placement,
and the audit log names the person.
Semantics:
- the role list REPLACES the target's role union for the session and never
widens it; every requested role must already be granted to the target;
- current_user() returns the target, so user-bound row policies and
current_user()-keyed predicates evaluate as the person; the audit log records
the person as the user;
- session-only and one-shot: a second SU in a switched session is refused;
resetConnection() / COM_CHANGE_USER revert to the AUTHENTICATED identity, never
to the target's full roles; nothing is persisted;
- a builtin session_is_narrowed() (BOOLEAN, folded on the FE like current_user())
lets policies and diagnostics tell a switched session apart;
- the implicit information_schema / mysql read baseline is kept in a narrowed
session, so clients keep working; direct/default-role grants are dropped;
- the narrowed session keeps the person's own WORKLOAD GROUP usage (placement
follows the person; never wider than the person's own session).
One choke point: Auth.getRolesByUserWithLdap returns the session override when
one is set on the ConnectContext; everything downstream (privilege checks, row
policies, SHOW GRANTS for the session) follows from that, with no change to the
privilege tables.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Raghvendra Singh <raghav@cashify.in>
…/BE boundary A session narrowed by `SU ... WITH ROLES (...)` is narrowed by ConnectContext state that Auth.getRolesByUserWithLdap consults. Two kinds of work leave that context behind and were authorized against the target's FULL role union: 1. BE->FE metadata RPCs. information_schema and mysql tables, the metadata table functions and processlist are served by BE scanners that call back into an FE handler thread carrying only current_user_ident, so a narrowed session saw off-scope database, table, column and view NAMES, the results of every per-table / per-database / catalog / ADMIN check in MetadataGenerator, and every session in processlist (data access itself was already scoped by table privilege and row policy at execution time). 2. Statements forwarded to the master FE, which rebuilds the session from TMasterOpRequest; the origin refused to forward at all. Carry the narrowing instead, on the thrift ids already reserved for exactly this: current_roles on TGetDbsParams / TGetTablesParams / TDescribeTablesParams / TSchemaTableRequestParams / TMetadataTableRequestParams / TShowProcessListRequest, current_roles + is_su_user on TMasterOpRequest, and current_roles on the schema and metadata scan plan nodes (SchemaScanNode / MetadataScanNode stamp it; the BE lifts it into the scanner parameter and every scanner that identifies the caller forwards it). On the FE, one helper (FrontendServiceImpl.withSessionRoleOverride) runs a handler under a thread-local narrowing keyed by the caller identity, consulted by Auth.getRolesByUserWithLdap and cleared in a finally because handler threads are pooled; getDbNames / getTableNames / listTableStatus / describeTables / fetchSchemaTableData / showProcessList delegate to their unchanged bodies through it. A narrowed request that names no caller is refused rather than run against the full union. Forward-to-master: the origin sets is_su_user + current_roles from the session, and ConnectProcessor.applyForwardedSessionNarrowing installs them on the proxy session before executing (no role list = empty set, fail closed). An older master silently ignores both fields and a rolling upgrade upgrades the master last, so the origin still refuses to forward unless the master reports the same build in its heartbeat (Env.masterRunsSameBuild; Frontend.localBuildVersion is the one definition of that string). SU itself stays NoForward. Tests: SuUserNarrowingTest (the no-ConnectContext handler path), ForwardedSessionNarrowingTest (request carries the narrowing only when switched; the master installs it and drops personal grants; no roles = empty; no flag = unnarrowed), NarrowedMetadataRpcTest (DATABASE_PROPERTIES through the real handler: personal grant gone, role grant kept, nothing sticks to the thread, no identity = refused). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Raghvendra Singh <raghav@cashify.in>
… beside the effective user The audit log names the session's effective user. Under a session-narrowed (SU) switch that is the target identity, so the row no longer says who actually logged in and ran the statement through it. Add an `authenticated_user` audit field and audit_log column, right after `user`: the account that authenticated the connection, equal to `user` unless the session was switched. Every row carries it, so "everything run through <account>" is one predicate. Existing audit_log tables gain the column through the internal-schema upgrade path (add + reorder to the schema order); the loader keeps one field per schema column, which AuditLoaderTest now asserts explicitly. AuditLogHelperTest covers the mapping before, during and after a switch. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Raghvendra Singh <raghav@cashify.in>
…ng is the target's granted roles Replace the FE-config stand-ins the switch shipped with. The gate becomes a grantable privilege in MySQL's own vocabulary: PROXY_PRIV (bit 15, GLOBAL scope, implied by ADMIN_PRIV, grantable and revocable only on *.*.* like ADMIN_PRIV and NODE_PRIV, listed by SHOW GRANTS like any other privilege). The role ceiling is always the target user's granted roles -- the session can never exceed the person's real authority -- so the switcher-side ceiling option goes. The dormant role pattern goes too: with the role list mandatory the service is already bounded by what the person holds, and a role the person holds is one they may use directly. Removed: Config.switch_user_users, switch_user_role_ceiling, su_only_roles_pattern and Auth.isSuOnlyRole. Auth.getGrantedRoleNamesRaw is now getGrantedRoleNames. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Raghvendra Singh <raghav@cashify.in>
…witch A service account holding PROXY_PRIV switches a session to a person restricted to one of the person's roles: the requested role's grant works, the person's direct grant is inert, name visibility (SHOW DATABASES, information_schema.tables) follows the narrowed set, the switch is one-shot, a role the person does not hold is refused, an account without PROXY_PRIV cannot switch, PROXY_PRIV is global-only and listed by SHOW GRANTS, and the person's own login is unaffected. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Raghvendra Singh <raghav@cashify.in>
The FE build rejects JUnit 3/4 in tests; the SU and audit tests used org.junit.Assert. Switch them to org.junit.jupiter.api.Assertions (the one message argument moves to the end of its call). Two fixes found by running them: the contract test installs the service account's ConnectContext as the thread-local before exercising the gate, so its GRANT PROXY_PRIV was checked against the service account -- grant as the admin session; and the regression suite grants the framework's default database to both test accounts, since every connection carries it and Doris refuses a connection without a privilege on it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Raghvendra Singh <raghav@cashify.in>
Since the authorization plugin SPI landed (PR apache#66770), every privilege check in the FE goes through AccessTranslation, whose class initialization refuses a privilege that has no access action. PROXY_PRIV had none, so on top of current master the first privilege check of any FE - CREATE DATABASE in the test harness included - failed with ExceptionInInitializerError. PROXY_PRIV now stands for a PROXY action: - AccessAction gains PROXY (only ever granted globally, like NODE), and AccessTranslation maps the privilege and the action to each other. - The recorded plugin API surface gains the constant, and the api major is bumped to 2.0 (minor zeroed) in the same commit, as the surface rule asks for any addition: a plugin built against 1.x would otherwise be admitted and meet an action it has never seen. - The Doris Ranger service has no access type for switching the session, so DorisAccessType answers PROXY with ADMIN: a Ranger-authorized cluster grants SU to its administrators and to nobody else, which is exactly what the engine's own predicate (ADMIN_PRIV implies PROXY_PRIV) already says. - The access-control behaviour baseline gains the PROXY column: it is answered wherever ADMIN is, because no fixture user holds PROXY_PRIV. Signed-off-by: Raghvendra Singh <raghav@cashify.in> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Since the execution layer fills the forward request through the session's protocol adapter (PR apache#67900), building one reads the client's negotiated capabilities; a bare test ConnectContext has none, so the probe that checks what the origin FE sends for a narrowed session now sets the default capability first, as FEOpExecutorFlightForwardTest does. Signed-off-by: Raghvendra Singh <raghav@cashify.in> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
### What problem does this PR solve? Issue Number: N/A Related PR: apache#67672 Problem Summary: After SU switches a connection to a user with a restricted role set, COM_CHANGE_USER clears that restriction before checking the replacement credentials. A forbidden root/admin target or a failed authentication returns an error while keeping the previous effective identity. Subsequent privilege checks then use that user's full role union, including direct grants excluded by SU. Clear SU state only after password authentication succeeds, immediately before installing the replacement identity. Failed changes retain the existing identity and narrowed roles. Add tests using the real authorization manager and MySQL change-user handler for forbidden accounts, failed authentication, successful reauthentication, and connection reset. ### Release note Keep SU session role restrictions active when COM_CHANGE_USER fails. ### Check List (For Author) - Test: Unit Test - 78 FE unit tests passed through run-fe-ut.sh, including 4 new connection lifecycle tests. Two new tests failed on the original implementation. - FE build and Checkstyle passed through build.sh --fe. - Behavior changed: Yes. A failed COM_CHANGE_USER preserves the current SU identity and role restriction. - Does this need documentation: No. This fix enforces the existing SU session contract; documentation for the feature remains tracked in apache#67672.
61c5b8e to
39e05e6
Compare
|
run buildall |
|
/review |
There was a problem hiding this comment.
Static review of PR 67672 converged after two bounded rounds. The implementation does carry SU identity/role data through the main plan and statement-forwarding paths, and the Thrift additions are optional and wire-compatible across branch-3.1, 4.0, 4.1, 4.2, and master. The review found nine verified issues:
- Four P1 authorization/compatibility gaps: TGetTables privilege metadata handlers ignore current_roles; SCH_USER/mysql.user ignores it; workload-group privilege enumeration bypasses the narrowed role filter; and BE-to-FE metadata callbacks can reach older FEs that silently ignore the new field during rolling upgrade.
- One P1 expression-folding defect: session_is_narrowed() is evaluated in a context-free fold path that must preserve context-dependent functions and can dereference a null context.
- Four P2 correctness/lifecycle gaps: reset applies target-specific timeout defaults before restoring the authenticated identity; omitted WORKLOAD GROUP keeps the switcher's explicit session setting; REST and forwarded audit paths lose authenticated-user attribution; and target-role ceiling snapshots race Auth's mutable role state without the read lock.
Checkpoint conclusions: the feature's stated narrowing goal is not fully achieved until these paths are fixed; the main data-visibility risk is in metadata and privilege enumeration rather than the core role replacement. Concurrency review found the unsynchronized role snapshot and the executor-thread boundary for ThreadLocal narrowing. Lifecycle review found the reset ordering and forwarded proxy audit identity issues. Protocol review found no field-id collision, required field, or API-versioning omission; the semantic old-FE gap is reported separately. Parallel metadata scanners and handlers were checked, and the existing review threads contain no duplicates. Tests and regression cases were inspected but not executed because this invocation is static-only. No additional user-provided focus was supplied. No unresolved candidates remain after the final sweep, so the review converged.
Review converged after 2 round(s).
| if (nullptr != _param->common_param->current_user_ident) { | ||
| table_params.__set_current_user_ident(*(_param->common_param->current_user_ident)); | ||
| if (!_param->common_param->current_roles.empty()) { | ||
| table_params.__set_current_roles(_param->common_param->current_roles); |
There was a problem hiding this comment.
[P1] Install current_roles in every TGetTables metadata handler. These scanners now send the SU role subset here, but listTableMetadataNameIds, listTablePrivilegeStatus, listSchemaPrivilegeStatus, and listUserPrivilegeStatus never call withSessionRoleOverride; their Auth checks therefore run with no ConnectContext and resolve the target's full role union. A narrowed session can regain excluded direct SHOW/SELECT/GRANT rows, and the name/ID handler performs its check in a new executor thread where a handler ThreadLocal would not propagate. Apply the override inside each handler/task or pass the role set explicitly before checking privileges.
| // SU narrowing: carry the SU-narrowed role subset from the FE plan to the scanners so the | ||
| // BE->FE metadata RPCs narrow name visibility (empty/unset = no narrowing, prior behavior). | ||
| if (tnode.schema_scan_node.__isset.current_roles) { | ||
| _common_scanner_param->current_roles = tnode.schema_scan_node.current_roles; |
There was a problem hiding this comment.
[P1] Carry narrowing through SCH_USER as well. This stores TSchemaScanNode.current_roles, but SchemaUserScanner still builds a TShowUserRequest with only the user identity and showUser is not wrapped. If the target has a direct GRANT/ADMIN role omitted from SU, mysql.user can expose the target's full account list and privilege topology. Add a role field to this request and apply/clear it in the handler (or use the common metadata path).
| } | ||
| schema_table_request_params.__set_current_user_ident(*_param->common_param->current_user_ident); | ||
| if (!_param->common_param->current_roles.empty()) { | ||
| schema_table_request_params.__set_current_roles(_param->common_param->current_roles); |
There was a problem hiding this comment.
[P1] Honor the narrowed roles when enumerating workload-group privileges. The RPC now carries current_roles here and the handler installs it, but getUserRoleWorkloadGroupPrivs later reads userRoleManager.getRolesByUser directly and emits every target role's workload-group grants. A SU session therefore sees excluded role privileges in information_schema.workload_group_privileges; derive the filter from the narrowed role set for this metadata enumeration while keeping the separate placement-check widening.
| msg.schema_scan_node.setCurrentUserIdent(tCurrentUser); | ||
| // SU narrowing: carry the session's active role subset (current_roles) in the plan so the | ||
| // BE->FE metadata RPCs (getDbNames/getTableNames/listTableStatus/describeTables) narrow | ||
| // name visibility to the same set the session sees; null = normal session (no narrowing). |
There was a problem hiding this comment.
[P1] Gate BE metadata callbacks during rolling upgrades. This sends the SU role subset to FE RPCs, but old FEs treat the field as reserved/unknown and authorize the target's full role union. SchemaScanNode can call every alive FE for several schema tables, and other metadata paths call the master; unlike FE-to-master SQL forwarding, these calls have no same-build check. Route narrowed metadata only to compatible FEs or fail closed until all peers understand current_roles.
| return new VarcharLiteral(res); | ||
| } | ||
|
|
||
| @Override |
There was a problem hiding this comment.
[P1] Preserve session_is_narrowed() in context-free folding. visitSessionIsNarrowed ignores foldContextDependentExpressions and dereferences context.cascadesContext; evaluateWithoutContext passes a null context, so expressions such as a metadata predicate can throw or be folded to FALSE for every normal session. Add the same guard as visitCurrentUser/visitSessionUser and only evaluate it when context folding is enabled.
| command = MysqlCommand.COM_SLEEP; | ||
| returnRows = 0; | ||
| // A narrowed session reverts to the AUTHENTICATED identity on connection reset — | ||
| // dropping only the override would widen the session to the target's full roles. |
There was a problem hiding this comment.
[P2] Restore the authenticated identity before resetting session defaults. resetConnection calls resetSessionVariable() while currentUserIdentity is still the SU target, so applyUserSessionVariableDefaults() loads the target's per-user query/insert timeouts; revertSessionNarrowing() then switches back without recalculating them. After COM_RESET_CONNECTION, the original account runs with the target's settings. Revert first or reapply defaults after the revert.
| // target's default_workload_group when omitted) is checked per query against the | ||
| // narrowed set widened with the target's own granted roles | ||
| // (Auth.getRolesForWorkloadGroupCheck): the person's lane follows the person. | ||
| ctx.getSessionVariable().setWorkloadGroup(workloadGroup); |
There was a problem hiding this comment.
[P2] Recompute the target workload group when the clause is omitted. This only sets SessionVariable.workloadGroup for an explicit clause; WorkloadGroupMgr otherwise honors the switcher's already-set session value before looking up the target's default. Thus SET workload_group='switcher_lane'; SU target ... executes as the target in the wrong lane, contrary to the documented omitted-clause behavior.
| @@ -194,6 +195,13 @@ protected TMasterOpRequest buildStmtForwardParams() throws AnalysisException { | |||
| params.setUserIp(ctx.getRemoteIP()); | |||
| params.setStmtId(ctx.getStmtId()); | |||
| params.setCurrentUserIdent(ctx.getCurrentUserIdentity().toThrift()); | |||
There was a problem hiding this comment.
[P2] Preserve the authenticated identity in every audit path. The forwarding additions carry only roles here; the master proxy applies them but leaves authenticatedIdentity null, so forwarded SU statements are audited with the target as both users. The REST AFTER_QUERY builder also omits setAuthenticatedUser, leaving the new column blank. Carry the switcher identity in the forward request and populate the field in all AFTER_QUERY emitters (or provide a safe common fallback).
| } | ||
|
|
||
| Auth auth = Env.getCurrentEnv().getAuth(); | ||
| Set<String> targetRoles = auth.getGrantedRoleNames(userIdentity); |
There was a problem hiding this comment.
[P2] Snapshot target grants under Auth's read lock. getGrantedRoleNames iterates UserRoleManager/LDAP state without acquiring Auth.readLock, while SU invokes it outside a lock; a concurrent GRANT/REVOKE or LDAP refresh can race the subset check and accept/reject inconsistently or throw during iteration. Protect the snapshot with the existing Auth lock (and release before any external work if needed).
FE UT Coverage ReportIncrement line coverage |
TPC-H: Total hot run time: 28754 ms |
TPC-DS: Total hot run time: 151070 ms |
ClickBench: Total hot run time: 24.29 s |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
… predicate The SU narrowing used a null sessionRoleOverride as the "not narrowed" sentinel and every reader null-checked the collection getter. A Mockito-mocked ConnectContext (CloudAuthTest since the JUnit 4 removal, apache#67396) answers an EMPTY set for that getter, so root looked narrowed to zero roles and every privileged command was denied. Add ConnectContext.isSessionRoleNarrowed() and read it at every site (Auth, FEOpExecutor, StmtExecutor, SchemaScanNode, MetadataScanNode, the session_is_narrowed() fold). An empty override set keeps its meaning (narrowed to the baseline only); the predicate is the sentinel. Signed-off-by: Raghvendra Singh <raghav@cashify.in> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 8a71d77)
The SU audit column sits after user in AUDIT_SCHEMA; the nonConcurrent audit suite's expected DESC output still listed the old schema.
…ed narrowing listTableMetadataNameIds, listTablePrivilegeStatus, listSchemaPrivilegeStatus and listUserPrivilegeStatus ran without withSessionRoleOverride, so a session-narrowed (SU) session's information_schema reads through those scanners were authorized against the target's full role union instead of the carried subset. TShowUserRequest carried no role subset at all: it gains current_roles, the BE user scanner sends it like the other scanners, and showUser runs under it, so mysql.user under SU shows what the narrowed roles allow. Review findings P1-1 and P1-2 on the SU pull request. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…nts and the REST query path A statement forwarded to the master carried only the narrowed role subset, so the master's audit row recorded the switched-to target as the account that logged in. TMasterOpRequest gains authenticated_user_ident: the origin FE sets it beside is_su_user/current_roles and the master installs it on the proxy session, so authenticated_user is the switcher on both FEs. The REST table query plan path now fills authenticated_user like the MySQL path does. Review finding P2-3 on the SU pull request. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…plus four review fixes - Compute-group (CLUSTER) USAGE joins workload-group USAGE on the placement role set: the narrowed set widened with the person's own granted roles. Stage and storage-vault usage are data access and stay narrowed. The SHOW output that enumerates workload-group and compute-group privileges reads the same set, so a narrowed session lists exactly what it can use (P1-3). The regression suite grants the cloud-mode compute group to both accounts, which is why its SU session failed in cloud_p0. - session_is_narrowed() honours the context-dependent fold guard like current_user() (P1-5). - resetConnection reverts the switch before the session variables are rebuilt, so the per-user defaults applied there are the authenticated account's (P2-1). - SU without a WORKLOAD GROUP clause clears the switcher's lane, so the per-query resolution falls through to the target's default group (P2-2). - The granted-role snapshot behind the SU ceiling runs under Auth's read lock (P2-4). Tests: SuUserNarrowingTest (lane reset), CloudAuthTest (compute-group placement under narrowing, in the mocked cloud harness the cluster check needs), FoldConstantTest (fold guard). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ed on a mixed-build FE set The BE answers most information_schema scans through the coordinating FE itself, which applies the carried narrowing. Two shapes leave it: the master-routed TABLES scan (enable_schema_scan_from_master_fe) and the tables that fan out to every alive FE. An FE of an older build ignores current_roles and authorizes the target's full role union, so a session-narrowed session refuses those scans while the FE set runs mixed builds, exactly as a forwarded statement already does (Env.masterRunsSameBuild). Review finding P1-4 on the SU pull request (the rolling-upgrade window). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… "self" credential change under the switch
PROXY_PRIV was ADMIN_PRIV in disguise. Nothing refused root or admin as a target
and the role-name check ran with canBeAdmin=true, so `SU 'admin'@'%' WITH ROLES
('admin')` handed any PROXY_PRIV holder ADMIN_PRIV on *.*.*; every account
granted the admin role, and every custom role carrying a global ADMIN/NODE/GRANT
bit, was another way up. With the "self" branch of SET PASSWORD the switched
session could then reset the target's password and keep the cluster.
The switch now refuses the built-in accounts as targets (the COM_CHANGE_USER
rule), refuses the built-in operator/admin roles and the per-user default role
(checkRoleName with canBeAdmin=false), and after the granted-roles ceiling
compares the union of the requested roles' GLOBAL privilege bits with what the
switching account holds: a role conferring ADMIN_PRIV, NODE_PRIV or GRANT_PRIV
is refused unless the switcher already holds that bit (Auth.getGlobalPrivsOfRoles).
Narrowing can only narrow.
The two "is this the user itself" exemptions that keyed on currentUserIdentity
now also require that the session was not switched: SET PASSWORD and the COMMON
keys of SET PROPERTY (default_workload_group, default_init_catalog, compute
group, quota.*) take the GRANT / ADMIN privilege of the narrowed set in an SU
session, as they do for any other account. The PROXY gate reports the access-
denied error code (1227) with the PROXY_PRIV token like its sibling gates.
Tests: SuUserNarrowingTest gains the ladder cases (admin/root target, admin/
operator/default role names, ADMIN_PRIV- and GRANT_PRIV-bearing roles for a
PROXY-only switcher and for an administrator, a non-analyzable identity) and the
closed self branches; the regression suite refuses SU to admin, the operator
role, and SET PASSWORD / SET PROPERTY inside the narrowed session.
Review findings F-01, F-06, F-16 and F-25 on the SU pull request.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… and gate every SQL forward masterRunsSameBuild() was false on every follower and observer, forever. Only the master runs HeartbeatMgr; the other FEs learn heartbeat state by replaying the HbPackage journal, which is Gson-serialized under the exclusion strategy that skips every field without @SerializedName -- and FrontendHbResponse.version had none. So fe.getVersion() of the master's entry was always null off-master, and every forwarded statement of a narrowed session on a non-master FE failed with the "different build" error on a fully upgraded cluster. The version is now annotated; an older FE replaying a newer master's package ignores the extra key (Gson), and a newer follower replaying an older master's package keeps null and stays closed, as intended. The gate itself protected forwardToMaster only. KILL QUERY for a query not found locally fans out as SQL to every other FE through FEOpExecutor, the one other FE->FE SQL sender, where an old remote FE would run the proxy session with the target's full role union. The gate moves into FEOpExecutor.buildStmtForwardParams, the single place that sets is_su_user, keyed on the receiving FE's address: Env.frontendRunsSameBuild(host, rpcPort) (this FE itself, or an alive FE whose journaled build equals ours); masterRunsSameBuild() delegates to it. Tests: ForwardedSessionNarrowingTest replays a FrontendHbResponse through the Gson round trip of an HbPackage onto a Frontend and asserts the build lands; a narrowed forward to an FE of unknown build is refused while the known one is taken; the probe now targets this FE's own address. Review findings F-02 and F-20 on the SU pull request. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…et's grants, listed consistently The override was pinned by name at switch time: narrowedRoleSet resolved the names through roleManager alone and the ceiling (getGrantedRoleNames) ran once, in SuUserCommand. A REVOKE of the role from the target, a DROP USER, or a DROP ROLE + CREATE ROLE under the same name were not honoured for the life of a pooled gateway session, while the person's own session re-reads its grants on every check. narrowedRoleSet now takes the target and intersects the override with getGrantedRoleNames(target) on every resolution -- live session, forwarded proxy session and BE->FE RPC thread alike -- so a revoked role drops out at the next check and a dropped target keeps only the information_schema/mysql baseline. The live-session path also resolved the full role map and the LDAP roles before discarding them when an override existed; the override test now comes right after the RPC thread-local, before any of that work. SHOW GRANTS mixed three resolutions: the Roles column (non-LDAP branch) and the storage-vault column read the raw user->role map, so a narrowed session listed roles it does not have, while every other column was narrowed. Both now resolve through getRolesByUserWithLdap like the rest. The synthetic baseline role was named `su_narrowing_baseline`, a name a row policy could be bound to and that the LDAP branch of SHOW GRANTS listed; it now carries the default-role prefix (so it can be neither CREATEd nor bound -- both validate the role) and is skipped by getRoleNamesByUserWithLdap, so no listing shows it. It is built once at class load from constant inputs and can no longer be null: the unreachable catch(Exception)/null branch is gone, a failure to build it fails the FE fast. Tests: SuUserNarrowingTest covers REVOKE after the switch, DROP ROLE + CREATE ROLE under the same name, DROP USER of the target, the SHOW GRANTS Roles column inside the narrowed session, and the unnameable baseline role. Review findings F-03, F-11, F-12 and F-23 on the SU pull request. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e narrowing choke point
EngineAuthorizationContext.rolesOf, what a ranger-hive or third-party
authorization source is told when it asks the engine who holds which roles,
read Auth.getRolesByUser(ident, false): the raw user->role map, never
getRolesByUserWithLdap. So a role-bound Ranger policy on a ranger-hive catalog
evaluated the target's FULL role union for a session-narrowed (SU) session, and
`SU alice WITH ROLES ('tenant_42')` could read what a policy for tenant_43
allowed, while the same session against an internal table was narrowed.
The bridge now calls Auth.getEffectiveRoleNames: getRoleNamesByUserWithLdap
without the default role, which honours the live override, the forwarded proxy
narrowing and the RPC thread-local exactly as the built-in checks do, includes
the LDAP-mapped roles (Doris roles the identity holds), and never names the
synthetic SU baseline. A source is never told a role the session cannot exercise.
Tests: EngineAuthorizationContextTest mocks the new resolver; SuUserNarrowingTest
asserts, against the real Auth, that rolesOf is narrowed by a session override
and by the RPC thread-local, and that another identity's roles are untouched.
Review finding F-04 on the SU pull request.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…the GRANT gate stays narrowed The workload-group "placement" widening handed the whole widened role set to Auth.checkWorkloadGroupPriv, which is also the gate of GRANT/REVOKE ... ON WORKLOAD GROUP (predicate USAGE AND GRANT), and Role.checkWorkloadGroupPriv ORs each role's GLOBAL privileges into the shared savedPrivs first. A session narrowed to a role without workload-group grants could therefore grant or revoke group privileges to third parties with the GRANT_PRIV that lives only in the person's direct grants -- the grants the switch is meant to leave inert. The same shape covered the compute-group (CLUSTER) leg of checkCloudPriv. The widening is now one question: "may this session run here?". After the narrowed set has said no, and only when the predicate is satisfiable by USAGE alone (so the GRANT gate's USAGE+GRANT never reaches it), the identity's own granted roles outside the override are consulted for the USAGE bit of their workload-group / compute-group grant on the named group (through the owning virtual compute group as well) -- never their global privileges, never GRANT_PRIV. The listings of grants go back to the narrowed set: the SHOW GRANTS compute-group column and workload_group_privileges list what the narrowed session holds; the lanes it may run in are answered by the USAGE question, which SHOW WORKLOAD GROUPS and SHOW CLUSTERS ask. The widening keyed on the live ConnectContext, so SHOW WORKLOAD GROUPS (this FE) and information_schema.workload_groups (through the BE, on a handler thread with the RPC thread-local) disagreed for one session. The narrowing in force is now read from either source (Auth.narrowingOf), so both legs answer alike. Tests: SuUserNarrowingTest adds the leak case -- a direct USAGE+GRANT on a group, SU to a role without it: the group stays usable, the GRANT gate and the GRANT statement are refused, and the RPC leg answers the same; the regression suite compares SHOW WORKLOAD GROUPS with information_schema.workload_groups inside the narrowed session. The existing workload-group and compute-group placement tests keep their assertions. Review findings F-05 and F-13 on the SU pull request. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ask contexts and KEY folds follow the session A persisted job stores a UserIdentity and nothing else about the session that minted it, and its tasks re-plan a read later on a job thread under that identity alone -- the target's FULL role union: the excluded roles' PERMISSIVE row policies apply, session_is_narrowed() folds FALSE, and the job outlives the session and any later REVOKE. EXPORT needs SELECT only and ships SELECT ... INTO OUTFILE to a switcher-chosen path; CREATE JOB ... ON STREAMING needs LOAD only and lands the re-planned SELECT (a JOIN with a policy-filtered table is kept) into a table the session can read, on every new file; ON SCHEDULE re-plans with the same policy view. Both are now refused in a session-narrowed (SU) session with the access-denied error code: "... is not allowed in a session-narrowed (SU) session; the job would run outside the session's role narrowing". Persisting the narrowing on ExportJob/AbstractJob and installing it in the task context is a possible follow-up; it needs the forwarded authenticated identity and a task-time re-check of the ceiling, and is not done here. Two smaller sinks of the same shape are closed in place. A child ConnectContext built for a task thread copied getCurrentUserIdentity() only -- the target without the override -- so the connector rewrite's INSERT-SELECT (and the routine-load workload-group probe) ran under the full union; both now use ConnectContext.inheritIdentityFrom(parent), which carries the identity and the narrowing together. A routine-load task folds `KEY db.k` references of the column mapping per task under the stored identity (SHOW on the key's database); the same authorization now runs at creation under the live session, so a narrowed session that may not read the key cannot create a job that resolves it. Tests: SuUserNarrowingTest refuses EXPORT and both CREATE JOB forms inside a narrowed session, authorizes a KEY reference at creation under the narrowed set, and shows a child context denying what the session denies; the regression suite refuses EXPORT and CREATE JOB ON SCHEDULE in the narrowed session. Review findings F-07, F-08, F-17 and F-26 on the SU pull request. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…out; a switched forward without roles is refused
The FE->FE SHOW PROCESSLIST fan-out (fetch_all_fe_for_system_table, on by
default) built TShowProcessListRequest with current_user_ident only: the
receiving handler was wrapped, but this sender was never swept, so every remote
FE ran listConnectionForRpc's ADMIN check against the target's full role union
and a tenant-narrowed session whose target holds an excluded ADMIN-bearing role
saw every user's session with its SQL on every other FE. The request builder
(ShowProcessListCommand.buildRequest) now sets current_roles when the session is
narrowed, the shape FEOpExecutor and SchemaScanNode already use; and because an
FE of an older build ignores the field, the fan-out fails closed while the FE
set runs mixed builds, through Env.aliveFrontendsRunSameBuild -- the check
SchemaScanNode carried privately for its all-FE scans, now shared.
The two sides of the current_roles wire field had two meanings: the BE forwards
a plan's set only when it is non-empty ("empty = not narrowed"), while the
master narrowed a switched forward without a role list to the empty set
("empty = nothing"). The master now refuses such a request (and an explicitly
empty one) with the access-denied error code instead of installing an empty
override, so an installed narrowing is never empty and "absent = not narrowed"
is the one meaning everywhere; the grammar already requires at least one role
on a live session. The refusal is reported to the origin FE through the normal
proxy result (applyForwardedSessionNarrowing runs first inside the execution
try, with its own catch).
Tests: ShowProcessListCommandTest covers the request builder for a plain and a
narrowed session; ForwardedSessionNarrowingTest replaces the "narrows to the
empty set" case with the refusal of a switched request without roles and with
an empty set.
Review findings F-09 and F-10 on the SU pull request.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…arget is named honestly, and the switch drops the switcher's caches Four session-lifecycle gaps of the switch, closed in SuUserCommand and ConnectContext. A login runs PasswordPolicyManager.checkAccountLockedAndPasswordExpiration; the switch did not, so an account locked by ACCOUNT_LOCK or by failed logins, or one whose password expired, could still be assumed through SU. The switch now runs the same check on the target and refuses with its reason. (MySQL judges a proxy login by the proxying account's lock; a switch to a locked person is refused here, since the administrator's lock is meant to stop that person's sessions.) With LDAP authentication the existence probe (getGrantedRoleNames, keyed by name) accepted a target with no Doris user entry under ANY host string, so the session ran as an identity that never existed, with a switcher-chosen host in current_user() and the audit row. A target without a local entry must now exist in LDAP (Auth.ldapUserExists) and be named with host '%', the way an LDAP-only account is known. SU left the per-connection prepared-statement map intact, so a short-circuit point query prepared before the switch executed afterwards with the plan that was authorized under the switcher, audited as the target; and the cloud compute-group cache (cloudCluster) was neither re-derived at the switch nor cleared when it ended, so a narrowed session failed on, or silently ran in, the switcher's group, and a reverted switcher kept the target's. The switch is now one ConnectContext operation (applySessionNarrowing) that drops both caches; leaving the switch (revert on reset, clear on COM_CHANGE_USER) drops the cached group and the workload-group lane the switch chose, so the identity that owns the session next resolves placement for itself -- the two leave-the-switch paths agree. A non-switched session's lane is untouched by COM_CHANGE_USER as before. Tests: SuUserNarrowingTest refuses a locked target and switches once unlocked, and shows the prepared statements and the compute-group cache dropped at the switch and the cache dropped on revert and on clear; MysqlConnectProcessorSuTest shows a successful COM_CHANGE_USER leaving the switch's lane. The LDAP shape cannot be exercised in the unit harness (no LDAP) and is traced from the code. Review findings F-14, F-15, F-18, F-19 and F-29 on the SU pull request. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e key carries the narrowing, and the tests cover the headline behaviours Four small points and the test gaps of the review, in one commit. user() / session_user() folded getUserWithLoginRemoteIpString(), which derives from currentUserIdentity -- the target after the switch -- so a client could not tell a proxied session from the person's own. MySQL's proxy model keeps USER() on the account that authenticated and CURRENT_USER() on the proxied one; user() now folds from the authenticated identity when the session is switched, while session_user() and current_user() stay on the effective identity. The FE SQL-cache key was catalog.db:identity:sql, so a person's own session and a gateway session narrowed as that person shared one entry and, whenever their privilege or policy views differed, each hit of one evicted the other's (the correctness gate on every hit was never affected). The key now carries the sorted override of a narrowed session. The SchemaScanNode note states the BE-before-FE dependency: an older BE drops the plan node's current_roles and its RPCs reach the FE without roles, where the handler runs un-narrowed -- the mirror of an older FE ignoring the field, and the reason BEs are upgraded first. Tests. The COM_CHANGE_USER case named "failed authentication" took the unknown- user branch (the fixture users have no password); it is renamed, and a rejected- password case for an account with a password (a 20-byte scramble that cannot match) now exercises the mismatch branch. NarrowedMetadataRpcTest covers every name-visibility wrapper (getDbNames, getTableNames, listTableStatus, describeTables) with the caller named by identity and by the deprecated user/user_ip pair, plus showProcessList with a target whose excluded role carries ADMIN_PRIV against a registered bystander session. The regression suite adds the headline row-policy behaviour: two PERMISSIVE policies bound to two of the person's roles and a RESTRICTIVE one bound to the person -- the person's own session sees both roles' rows, the session narrowed to one role sees that role's rows only. The negative unit cases of the ladder (default role, operator, admin, a non-analyzable identity), REVOKE after the switch and SHOW GRANTS inside the narrowed session landed with their fixes earlier in this series. An audit_log assertion stays out of the p0 suite: the audit plugin is a global switch the nonConcurrent audit suite flips, and AuditLogHelperTest covers the identity mapping. On the PR body (corrections to carry there): a narrowed request that names no caller is refused by fetchSchemaTableData only -- the other wrappers key the narrowing on the identity they synthesize from user/user_ip; the FrontendService fields sit on reserved ids, while TSchemaScanNode.18 and TMetaScanNode.4 are fresh ids; the reset/COM_CHANGE_USER revert is MySQL-protocol-only -- on Arrow Flight SQL the switch lasts until CloseSession. Review findings F-21, F-22, F-24, F-27, F-28, F-30 and F-31 on the SU pull request. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The placement listing in getUserRoleWorkloadGroupPrivs was the last plain use of java.util.HashSet in Auth; with it on getRoleNamesByUserWithLdap the import is unused and checkstyle (UnusedImports) refuses the build. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…tity-only context The previous commit made CreateRoutineLoadInfo's temporary context inherit the session's narrowing (F-17). That context exists only to resolve the job's workload group by name for an existence check -- placement, not data access, and the narrowed session may use every group the person's own session may use (the placement rule of this series). Narrowing the lookup therefore changes nothing a user can observe, and master has since moved that lookup into a static helper that builds its own identity-only context (apache#69749), so the inherited form would only conflict on merge. The data-access site of F-17, the connector rewrite's INSERT ... SELECT task context, keeps inheritIdentityFrom. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…at class level in SchemaScanNode Round-2 commit 3ba24ea added the all-FE mixed-build gate of a session-narrowed information_schema scan twice: once inside finalizeForNereids, where it belongs, and once more as a stray copy right after mixedBuildMessage(), at class level, followed by a brace that closed the class early. Round-3 commit 63ba606 re-touched the copy when it moved the helper into Env, so it survived both commits unnoticed; javac rejects it ("illegal start of type"), so fe-core did not build. The surviving gate in finalizeForNereids and setFeAddrList both key on SchemaTable.shouldFetchAllFe(), so nothing else changes. Candidate review finding F-01 (Blocker) on apache doris PR 67672. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…CLUSTER grant is stored under grantsComputeGroupUsage asked the own role's cloud-cluster table for USAGE_PRIV, but a GRANT USAGE_PRIV ON CLUSTER never stores that bit: GrantResourcePrivilegeCommand (and its REVOKE twin) run PrivBitSet.convertResourcePrivToCloudPriv first, which replaces a lone USAGE_PRIV with CLUSTER_USAGE_PRIV. The normal check passes because Role.checkCloudInternal satisfies PrivPredicate.USAGE, an OR over ADMIN, USAGE, CLUSTER_USAGE and STAGE_USAGE; the widening asked for the one bit that is never there and so never fired -- a session narrowed to a tenant role was refused the person's own compute group, and the new CloudAuthTest case (testNarrowedSessionKeepsPersonsComputeGroupUsage) failed by construction. The helper now accepts CLUSTER_USAGE_PRIV too (containsPrivs is any-of). The workload-group twin is untouched: workload-group grants are not converted (only CLUSTER and STAGE are) and really are stored as USAGE_PRIV. Candidate review finding F-02 (Blocker) on apache doris PR 67672. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…to its executor thread; every wrapped handler is tested withSessionRoleOverride installs the BE->FE request's role subset in Auth.RPC_SESSION_NARROWING, a ThreadLocal of the thrift handler thread, and listTableMetadataNameIdsImpl then submits its whole walk -- including its only privilege decision, checkTblPriv(currentUser, ..., SHOW) -- to a fresh single-thread executor, where the ThreadLocal is unset and no ConnectContext exists: getRolesByUserWithLdap fell through to the user->role map, and a narrowed session's information_schema.metadata_name_ids listed every table the target may SHOW through any role, the ones SU excluded included. This is the second half of review thread T9 on the pull request, which the round-2 wrapper answered on the handler thread only. The handler now captures the narrowing withSessionRoleOverride installed (Auth.captureRpcSessionNarrowing: the map keyed by the identity the wrapper synthesized, so the key has one source of truth and the user/user_ip fallback needs no second copy of that rule) and installs it on the executor thread for the duration of the task (Auth.installRpcSessionNarrowing, cleared in a finally). Capturing beats hoisting the check: the executor exists for the external-catalog timeout, and the per-table check sits behind db.getTables(), which is what the timeout bounds. The other wrappers are untouched. NarrowedMetadataRpcTest.testEveryNameVisibilityHandlerNarrows covered four of the eight wrapped handlers; it now drives all eight, by identity and by the deprecated user/user_ip pair: listTableMetadataNameIds (the executor-thread case), listTablePrivilegeStatus and listSchemaPrivilegeStatus (the personal rows on perso vanish, the role's rows on test stay -- a table-level twin of each db-level grant joins the fixture), and listUserPrivilegeStatus (gated on the caller's own global SHOW, which dave holds only through the ADMIN-bearing role the switch leaves out: rows un-narrowed, none narrowed). Candidate review findings F-03 (Major) and F-04 (Minor) on apache doris PR 67672. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…, and the un-narrowed role resolver Auth left public is gone Env.aliveFrontendsRunSameBuild was inserted between frontendRunsSameBuild's Javadoc and its method, so the first block documented the wrong method and frontendRunsSameBuild carried none (checkstyle's InvalidJavadocPosition skips comment siblings; the javadoc tool and the IDE hover do not). Each method now carries its own. Auth.getRolesByUser(UserIdentity, boolean) lost its last caller when the authorization-SPI role bridge moved to getEffectiveRoleNames; a public resolver that bypasses the narrowing choke point by construction invited the next bridge to use it. Removed; no caller remains anywhere under fe/ (UserRoleManager's own two-argument form is not this change's). getGrantedRoleNames is the sanctioned un-narrowed resolver. Candidate review findings F-05 (Nit) and F-06 (Nit) on apache doris PR 67672. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Local pipeline review — ✅ PASSschema: doris-repo-review/v1
status: PASS
pr: apache/doris#67672
commit: 815fb022174b77b2da4a78985f9dfad494978955
base: 46798454678d67c8dc47b048e9a6675ca79669bd
reviewed_at: 2026-11-03T09:58+05:30
reviewer: raghav-reglobe
model: claude-fable-5-1
effort: xhigh
findings: {blocker: 0, major: 0, minor: 0, nit: 2}
rounds: 2
converged: trueNotes for maintainers
Reviewed locally with the |
|
@morningman thank you for the rebase and the fix on top. I pushed 21 commits as a fast-forward on your head 39e05e6 (none of your commits are rewritten). Per thread:
Beyond the threads, two rounds of the local pipeline-style review (receipt above) drove the rest of the delta: the compute-group placement widening tests the bit a CLUSTER grant is stored under, the forward refuses a switched request without a role list, and the fail-closed list grew. One design call to flag: EXPORT and CREATE JOB (ON STREAMING / ON SCHEDULE) are refused in a narrowed session rather than persisting the narrowing into the job; if you would rather have the narrowing persisted, that is a follow-up PR I am happy to do. The PR body is updated accordingly (fresh vs reserved thrift ids, the MySQL-protocol-only revert, the refusal list). |
What problem does this PR solve?
Issue Number: close #67506
Related PR: #63239 (reserved the
current_roles/is_su_userids on the FrontendService request structs; the plan-node fields,TMasterOpRequest.authenticated_user_identandTShowUserRequest.current_rolestake fresh ids), #67444 (the same identity-in-request pattern formysql.user)Problem Summary:
A multi-tenant middle tier — an AI or BI gateway, an MCP server, an embedded-analytics backend — can't make Doris enforce the end user's entitlements, nor attribute the query to that person. Its choices today are one shared service account (no per-person audit, app-level authz) or holding every person's password and getting their full role union. What it needs is what MySQL's
PROXYprivilege and Oracle'sCONNECT THROUGHgive: authenticate as the service, then run this session as a named user, restricted to an explicit subset of that user's roles.This adds exactly that:
PROXY_PRIVis a new global privilege in MySQL's vocabulary (bit 15;ADMIN_PRIVimplies it; grantable only on*.*.*likeADMIN_PRIV/NODE_PRIV; shown bySHOW GRANTS). It is the only gate onSU.current_user()is the target, so user-bound row policies andcurrent_user()-keyed predicates evaluate as the person; the audit log records the person asuser, and a newauthenticated_usercolumn/field beside it records who actually logged in (equal touserunless switched).SUis refused. On the MySQL protocol,resetConnection()/COM_CHANGE_USERrevert to the authenticated identity, never to the target's full roles; Arrow Flight SQL has no such command, so there the switch lasts untilCloseSession. Nothing is persisted.session_is_narrowed()(BOOLEAN, FE-folded likecurrent_user()) lets policies tell a switched session apart.One choke point:
Auth.getRolesByUserWithLdapreturns the session override when one is set; privilege checks, row policies andSHOW GRANTSfollow from that with no change to the privilege tables. The information_schema/mysqlread baseline is kept so clients keep working, and the narrowed session keeps the person's own workload-group and compute-groupUSAGE(placement follows the person); stage and storage-vault usage stay on the narrowed set.Carrying the narrowing across the FE/BE boundary. Two kinds of work leave the
ConnectContextbehind and were authorized against the target's full role union: the BE→FE metadata RPCs behindinformation_schema/mysqltables, the metadata table functions and processlist (name and row leaks on the handler thread), and statements forwarded to the master. The narrowed role set now travels ascurrent_roleson the FrontendService request structs that #63239 reserved the ids for (TGetDbsParams,TGetTablesParams,TDescribeTablesParams,TMetadataTableRequestParams,TSchemaTableRequestParams,TShowProcessListRequest, andTMasterOpRequest34 withis_su_user35), and on fresh ids where nothing was reserved:TSchemaScanNode18 andTMetaScanNode4 (the plan nodes),TMasterOpRequest37 (authenticated_user_ident, so the master's audit row names the authenticating account too) andTShowUserRequest2. Every fresh id is unused on branch-3.1, 4.0, 4.1, 4.2 and master. On the FE one helper runs each handler under a thread-local narrowing keyed by the caller identity; the master installs the carried set on the proxy session before executing. Fail-closed choices: a narrowedfetchSchemaTableDatarequest that names no caller is refused with an error result; the other wrapped handlers key the narrowing on the identity they synthesize from the deprecateduser/user_ippair, the same identity their privilege checks already use; a switched forward without a role list is refused by the master; and because an older FE would silently ignore the fields (and a rolling upgrade upgrades the master last), a forward from a narrowed session is refused unless the destination FE reports the same build in its heartbeat — the same gate covers the SHOW PROCESSLIST fan-out and the all-FEinformation_schemascans, and every FE journals its build so followers can judge it.Not in this PR, happy to follow up: a per-target
GRANT PROXY_PRIV ON 'alice'@'%' TO ...form (needs a new priv table; the global form is MySQL's''@''wildcard case) and a no-listSUthat behaves like MySQLPROXYif parity is preferred.Release note
Add
SU 'user' WITH ROLES (...)— a session-narrowed identity switch (MySQL-style proxy authentication with mandatory role narrowing) gated by a new globalPROXY_PRIV, plussession_is_narrowed()and anauthenticated_useraudit column.Check List (For Author)
Test
auth_p0/test_su_session_narrowing.groovySuUserNarrowingTest,ForwardedSessionNarrowingTest,NarrowedMetadataRpcTest,MysqlConnectProcessorSuTest,CloudAuthTest,ShowProcessListCommandTest,EngineAuthorizationContextTest,FoldConstantTest,AuditLoaderTest,AuditLogHelperTestPROXY_PRIV)Behavior changed:
SU, new privilegePROXY_PRIV, new builtinsession_is_narrowed(), newauthenticated_usercolumn on__internal_schema.audit_log(added through the existing schema-upgrade path) and field infe.audit.log. Existing sessions are unaffected unless they runSU. In a narrowed session:EXPORTandCREATE JOB(ON STREAMING / ON SCHEDULE) are refused; theSET PASSWORD/SET PROPERTYself-shortcuts are closed; a locked or password-expired target cannot be assumed; a secondSU, andSUtoroot,adminor the operator role, are refused;user()names the authenticating account whilecurrent_user()/session_user()name the effective one. Wire: new optional thrift fields only — on the ids [fix](thrift) Reserve frontend service field ids #63239 reserved for the FrontendService request structs, and on fresh ids (checked free on branch-3.1/4.0/4.1/4.2/master) forTSchemaScanNode18,TMetaScanNode4,TMasterOpRequest37 andTShowUserRequest2. The FE heartbeat response now journals the responder's build (FrontendHbResponse.version, a Gson field older FEs ignore and newer FEs tolerate missing); otherwise no metadata/editlog format change beyond the new privilege bit (an FE downgraded below this version ignores bit 15). Rolling-upgrade note in the description (narrowed forwards fail closed until the master is upgraded).Does this need documentation?
Check List (For Reviewer who merge this PR)
🤖 Generated with Claude Code