This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new a3598ba5cc8 branch-4.1: [fix](auth) Fix HTTP API authentication 
framework for admin operations (#62411)
a3598ba5cc8 is described below

commit a3598ba5cc838ab978f7cabfb1fb5e9a9930dfd8
Author: Gavin Chou <[email protected]>
AuthorDate: Thu Apr 23 11:22:41 2026 +0800

    branch-4.1: [fix](auth) Fix HTTP API authentication framework for admin 
operations (#62411)
    
    Pick #60761 to branch-4.1
    
    ---------
    
    Co-authored-by: Claude Sonnet 4.5 <[email protected]>
    Co-authored-by: gavinchou <[email protected]>
---
 be/src/service/http/action/health_action.h         |   4 +-
 be/src/service/http/action/http_stream.cpp         |  11 +-
 be/src/service/http/action/http_stream.h           |   5 +-
 be/src/service/http/action/stream_load.cpp         |  11 +-
 be/src/service/http/action/stream_load.h           |   6 +-
 be/src/service/http/action/stream_load_2pc.cpp     |   6 +-
 be/src/service/http/action/stream_load_2pc.h       |   5 +-
 be/src/service/http/http_handler_with_auth.cpp     |   4 +
 be/test/service/http/http_auth_test.cpp            |  99 +++++++++-
 .../doris/httpv2/controller/BaseController.java    |   1 +
 .../apache/doris/httpv2/rest/BackendsAction.java   |   4 -
 .../doris/httpv2/rest/BootstrapFinishAction.java   |   4 +-
 .../doris/httpv2/rest/CheckDecommissionAction.java |   6 +-
 .../doris/httpv2/rest/CheckWalSizeAction.java      |   6 +-
 .../apache/doris/httpv2/rest/ConnectionAction.java |   6 +-
 .../apache/doris/httpv2/rest/DebugPointAction.java |  15 +-
 .../doris/httpv2/rest/ExtraBasepathAction.java     |   4 +-
 .../doris/httpv2/rest/FeVersionInfoAction.java     |   7 +-
 .../apache/doris/httpv2/rest/GetLogFileAction.java |   7 +-
 .../doris/httpv2/rest/GetSmallFileAction.java      |   7 +-
 .../org/apache/doris/httpv2/rest/HealthAction.java |   6 +-
 .../apache/doris/httpv2/rest/MetaInfoAction.java   |  16 +-
 .../doris/httpv2/rest/MetaReplayerCheckAction.java |   7 +-
 .../apache/doris/httpv2/rest/MetricsAction.java    |   5 +-
 .../apache/doris/httpv2/rest/MinidumpAction.java   |   7 +-
 .../apache/doris/httpv2/rest/ProfileAction.java    |  11 +-
 .../apache/doris/httpv2/rest/QueryStatsAction.java |  26 +--
 .../doris/httpv2/rest/RestBaseController.java      |  18 ++
 .../apache/doris/httpv2/rest/RowCountAction.java   |   7 +-
 .../apache/doris/httpv2/rest/SetConfigAction.java  |   6 +-
 .../org/apache/doris/httpv2/rest/ShowAction.java   |   7 +-
 .../doris/httpv2/rest/StmtExecutionAction.java     |   3 +-
 .../doris/httpv2/rest/StorageTypeCheckAction.java  |   7 +-
 .../doris/httpv2/rest/TableQueryPlanAction.java    |   2 +-
 .../doris/httpv2/rest/TableRowCountAction.java     |   2 +-
 .../doris/httpv2/rest/TableSchemaAction.java       |  17 +-
 .../org/apache/doris/httpv2/rest/UploadAction.java |  12 +-
 .../doris/httpv2/rest/manager/ClusterAction.java   |  11 +-
 .../doris/httpv2/rest/manager/NodeAction.java      |  13 +-
 .../httpv2/rest/manager/QueryProfileAction.java    |   9 +-
 .../apache/doris/httpv2/rest/HttpApiAuthTest.java  | 158 +++++++++++++++
 .../suites/auth/test_http_api_auth.groovy          | 216 +++++++++++++++++++++
 42 files changed, 641 insertions(+), 143 deletions(-)

diff --git a/be/src/service/http/action/health_action.h 
b/be/src/service/http/action/health_action.h
index f2d135d15f2..5a32012d2f7 100644
--- a/be/src/service/http/action/health_action.h
+++ b/be/src/service/http/action/health_action.h
@@ -27,7 +27,9 @@ class ExecEnv;
 // Get BE health state from http API.
 class HealthAction : public HttpHandlerWithAuth {
 public:
-    HealthAction(ExecEnv* exec_env) : HttpHandlerWithAuth(exec_env) {}
+    HealthAction(ExecEnv* exec_env)
+            : HttpHandlerWithAuth(exec_env, TPrivilegeHier::GLOBAL, 
TPrivilegeType::NONE) {}
+    // Use NONE type: public API, no auth required
 
     ~HealthAction() override = default;
 
diff --git a/be/src/service/http/action/http_stream.cpp 
b/be/src/service/http/action/http_stream.cpp
index e9426bde236..9e98199ac46 100644
--- a/be/src/service/http/action/http_stream.cpp
+++ b/be/src/service/http/action/http_stream.cpp
@@ -67,7 +67,10 @@ 
DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(http_stream_requests_total, MetricUnit::REQ
 DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(http_stream_duration_ms, 
MetricUnit::MILLISECONDS);
 DEFINE_GAUGE_METRIC_PROTOTYPE_2ARG(http_stream_current_processing, 
MetricUnit::REQUESTS);
 
-HttpStreamAction::HttpStreamAction(ExecEnv* exec_env) : _exec_env(exec_env) {
+HttpStreamAction::HttpStreamAction(ExecEnv* exec_env)
+        : HttpHandlerWithAuth(exec_env, TPrivilegeHier::GLOBAL, 
TPrivilegeType::LOAD) {
+    // Use LOAD privilege type: requires LOAD permission
+    // Note: _exec_env is set by parent class HttpHandlerWithAuth
     _http_stream_entity =
             
DorisMetrics::instance()->metric_registry()->register_entity("http_stream");
     INT_COUNTER_METRIC_REGISTER(_http_stream_entity, 
http_stream_requests_total);
@@ -154,6 +157,12 @@ Status HttpStreamAction::_handle(HttpRequest* http_req, 
std::shared_ptr<StreamLo
 }
 
 int HttpStreamAction::on_header(HttpRequest* req) {
+    // Call parent's auth check first
+    int ret = HttpHandlerWithAuth::on_header(req);
+    if (ret != 0) {
+        return ret; // Auth failed, return error
+    }
+
     http_stream_current_processing->increment(1);
 
     std::shared_ptr<StreamLoadContext> ctx = 
std::make_shared<StreamLoadContext>(_exec_env);
diff --git a/be/src/service/http/action/http_stream.h 
b/be/src/service/http/action/http_stream.h
index af39ce9bda9..03b6a7539a2 100644
--- a/be/src/service/http/action/http_stream.h
+++ b/be/src/service/http/action/http_stream.h
@@ -22,7 +22,7 @@
 #include <functional>
 
 #include "load/message_body_sink.h"
-#include "service/http/http_handler.h"
+#include "service/http/http_handler_with_auth.h"
 #include "util/client_cache.h"
 
 namespace doris {
@@ -31,7 +31,7 @@ class ExecEnv;
 class Status;
 class StreamLoadContext;
 
-class HttpStreamAction : public HttpHandler {
+class HttpStreamAction : public HttpHandlerWithAuth {
 public:
     HttpStreamAction(ExecEnv* exec_env);
     ~HttpStreamAction() override;
@@ -53,7 +53,6 @@ private:
     Status _handle_group_commit(HttpRequest* http_req, 
std::shared_ptr<StreamLoadContext> ctx);
 
 private:
-    ExecEnv* _exec_env;
     std::shared_ptr<MetricEntity> _http_stream_entity;
     IntCounter* http_stream_requests_total;
     IntCounter* http_stream_duration_ms;
diff --git a/be/src/service/http/action/stream_load.cpp 
b/be/src/service/http/action/stream_load.cpp
index ee3febc134d..7e0f4ba0977 100644
--- a/be/src/service/http/action/stream_load.cpp
+++ b/be/src/service/http/action/stream_load.cpp
@@ -90,7 +90,9 @@ static const std::string ASYNC_MODE = "async_mode";
 TStreamLoadPutResult k_stream_load_put_result;
 #endif
 
-StreamLoadAction::StreamLoadAction(ExecEnv* exec_env) : _exec_env(exec_env) {
+StreamLoadAction::StreamLoadAction(ExecEnv* exec_env)
+        : HttpHandlerWithAuth(exec_env, TPrivilegeHier::GLOBAL, 
TPrivilegeType::LOAD) {
+    // Use LOAD privilege type: requires LOAD permission
     _stream_load_entity =
             
DorisMetrics::instance()->metric_registry()->register_entity("stream_load");
     INT_COUNTER_METRIC_REGISTER(_stream_load_entity, 
streaming_load_requests_total);
@@ -203,6 +205,13 @@ Status 
StreamLoadAction::_handle(std::shared_ptr<StreamLoadContext> ctx) {
 }
 
 int StreamLoadAction::on_header(HttpRequest* req) {
+    // Call parent's auth check first
+    int ret = HttpHandlerWithAuth::on_header(req);
+    if (ret != 0) {
+        return ret; // Auth failed, return error
+    }
+
+    // Continue with stream load specific header processing
     streaming_load_current_processing->increment(1);
 
     std::shared_ptr<StreamLoadContext> ctx = 
std::make_shared<StreamLoadContext>(_exec_env);
diff --git a/be/src/service/http/action/stream_load.h 
b/be/src/service/http/action/stream_load.h
index 5803c1ea393..ce03e1cdf6f 100644
--- a/be/src/service/http/action/stream_load.h
+++ b/be/src/service/http/action/stream_load.h
@@ -21,7 +21,7 @@
 #include <string>
 
 #include "common/metrics/metrics.h"
-#include "service/http/http_handler.h"
+#include "service/http/http_handler_with_auth.h"
 
 namespace doris {
 
@@ -30,7 +30,7 @@ class Status;
 class StreamLoadContext;
 class HttpRequest;
 
-class StreamLoadAction : public HttpHandler {
+class StreamLoadAction : public HttpHandlerWithAuth {
 public:
     StreamLoadAction(ExecEnv* exec_env);
     ~StreamLoadAction() override;
@@ -56,8 +56,6 @@ private:
     Status _handle_group_commit(HttpRequest* http_req, 
std::shared_ptr<StreamLoadContext> ctx);
 
 private:
-    ExecEnv* _exec_env;
-
     std::shared_ptr<MetricEntity> _stream_load_entity;
     IntCounter* streaming_load_requests_total;
     IntCounter* streaming_load_duration_ms;
diff --git a/be/src/service/http/action/stream_load_2pc.cpp 
b/be/src/service/http/action/stream_load_2pc.cpp
index 4ce8f0df6b0..0239ed9fee6 100644
--- a/be/src/service/http/action/stream_load_2pc.cpp
+++ b/be/src/service/http/action/stream_load_2pc.cpp
@@ -39,7 +39,11 @@
 
 namespace doris {
 
-StreamLoad2PCAction::StreamLoad2PCAction(ExecEnv* exec_env) : 
_exec_env(exec_env) {}
+StreamLoad2PCAction::StreamLoad2PCAction(ExecEnv* exec_env)
+        : HttpHandlerWithAuth(exec_env, TPrivilegeHier::GLOBAL, 
TPrivilegeType::LOAD) {
+    // Use LOAD privilege type: requires LOAD permission
+    // Note: _exec_env is set by parent class HttpHandlerWithAuth
+}
 
 void StreamLoad2PCAction::handle(HttpRequest* req) {
     Status status = Status::OK();
diff --git a/be/src/service/http/action/stream_load_2pc.h 
b/be/src/service/http/action/stream_load_2pc.h
index 3e1b3076eee..939e9f8dbfa 100644
--- a/be/src/service/http/action/stream_load_2pc.h
+++ b/be/src/service/http/action/stream_load_2pc.h
@@ -19,14 +19,14 @@
 
 #include <string>
 
-#include "service/http/http_handler.h"
+#include "service/http/http_handler_with_auth.h"
 
 namespace doris {
 
 class ExecEnv;
 class HttpRequest;
 
-class StreamLoad2PCAction : public HttpHandler {
+class StreamLoad2PCAction : public HttpHandlerWithAuth {
 public:
     StreamLoad2PCAction(ExecEnv* exec_env);
 
@@ -36,7 +36,6 @@ public:
     std::string get_success_info(const std::string msg, const std::string 
txn_operation);
 
 private:
-    ExecEnv* _exec_env;
 };
 
 } // namespace doris
diff --git a/be/src/service/http/http_handler_with_auth.cpp 
b/be/src/service/http/http_handler_with_auth.cpp
index 4c977ddd9ec..4a30b5640b8 100644
--- a/be/src/service/http/http_handler_with_auth.cpp
+++ b/be/src/service/http/http_handler_with_auth.cpp
@@ -44,6 +44,10 @@ int HttpHandlerWithAuth::on_header(HttpRequest* req) {
         return 0;
     }
 
+    // When enable_all_http_auth is true, even NONE type APIs require 
authentication
+    // (enable_all_http_auth means "enable authentication for ALL HTTP APIs")
+    // Note: This overrides the default behavior where NONE type APIs bypass 
auth
+
     if (!parse_basic_auth(*req, &auth_info)) {
         LOG(WARNING) << "parse basic authorization failed"
                      << ", request: " << req->debug_string();
diff --git a/be/test/service/http/http_auth_test.cpp 
b/be/test/service/http/http_auth_test.cpp
index 74784f1f460..a738dd7922c 100644
--- a/be/test/service/http/http_auth_test.cpp
+++ b/be/test/service/http/http_auth_test.cpp
@@ -62,14 +62,16 @@ TEST_F(HttpAuthTest, enable_all_http_auth) {
     Defer defer {[]() { config::enable_all_http_auth = false; }};
     config::enable_all_http_auth = true;
 
-    // 1. empty auth info
+    // 1. empty auth info - on_header returns -1 and sends UNAUTHORIZED reply
+    // Note: when on_header returns -1, send_reply has been called internally,
+    // so we should NOT call evhttp_request_free (would cause double-free)
     {
         auto evhttp_req = evhttp_request_new(nullptr, nullptr);
         HttpRequest req1(evhttp_req);
         EXPECT_EQ(s_auth_handler.on_header(&req1), -1);
     }
 
-    // 2. empty param
+    // 2. empty param - on_header returns -1 and sends BAD_REQUEST reply
     {
         auto evhttp_req = evhttp_request_new(nullptr, nullptr);
         HttpRequest req2(evhttp_req);
@@ -77,7 +79,7 @@ TEST_F(HttpAuthTest, enable_all_http_auth) {
         EXPECT_EQ(s_auth_handler.on_header(&req2), -1);
     }
 
-    // 3. OK
+    // 3. OK - on_header returns 0 without calling send_reply
     {
         auto evhttp_req = evhttp_request_new(nullptr, nullptr);
         HttpRequest req3(evhttp_req);
@@ -88,4 +90,95 @@ TEST_F(HttpAuthTest, enable_all_http_auth) {
     }
 }
 
+// Test NONE privilege type - when enable_all_http_auth=true, even NONE type 
requires auth
+TEST_F(HttpAuthTest, privilege_type_none) {
+    Defer defer {[]() { config::enable_all_http_auth = false; }};
+    config::enable_all_http_auth = true;
+
+    // Create handler with NONE privilege type (like HealthAction)
+    HttpAuthTestHandler none_handler(nullptr, TPrivilegeHier::GLOBAL, 
TPrivilegeType::NONE);
+
+    // When enable_all_http_auth=true, even NONE type requires authentication
+    // (enable_all_http_auth means "enable authentication for ALL HTTP APIs")
+    // Without auth header, should fail with -1 (UNAUTHORIZED reply sent)
+    {
+        auto evhttp_req = evhttp_request_new(nullptr, nullptr);
+        HttpRequest req(evhttp_req);
+        // No authorization header - should fail
+        EXPECT_EQ(none_handler.on_header(&req), -1);
+        // Note: when on_header returns -1, send_reply has been called 
internally,
+        // so we should NOT call evhttp_request_free (would cause double-free)
+    }
+
+    // With valid auth header, should pass
+    {
+        auto evhttp_req = evhttp_request_new(nullptr, nullptr);
+        HttpRequest req(evhttp_req);
+        req._headers.emplace(HttpHeaders::AUTHORIZATION, "Basic cm9vdDo=");
+        req._params.emplace("table", "T");
+        EXPECT_EQ(none_handler.on_header(&req), 0);
+        // Note: when on_header returns 0, the request is NOT freed by 
send_reply
+        evhttp_request_free(evhttp_req);
+    }
+}
+
+// Test LOAD privilege type
+TEST_F(HttpAuthTest, privilege_type_load) {
+    // Create handler with LOAD privilege type (like StreamLoadAction)
+    HttpAuthTestHandler load_handler(nullptr, TPrivilegeHier::GLOBAL, 
TPrivilegeType::LOAD);
+
+    // When enable_all_http_auth=false, should pass without auth
+    config::enable_all_http_auth = false;
+    auto evhttp_req = evhttp_request_new(nullptr, nullptr);
+    HttpRequest req(evhttp_req);
+    EXPECT_EQ(load_handler.on_header(&req), 0);
+    evhttp_request_free(evhttp_req);
+}
+
+// Test different privilege types are distinct
+TEST_F(HttpAuthTest, privilege_types_distinct) {
+    Defer defer {[]() { config::enable_all_http_auth = false; }};
+    config::enable_all_http_auth = true;
+
+    // Create handlers with different privilege types
+    HttpAuthTestHandler admin_handler(nullptr, TPrivilegeHier::GLOBAL, 
TPrivilegeType::ADMIN);
+    HttpAuthTestHandler load_handler(nullptr, TPrivilegeHier::GLOBAL, 
TPrivilegeType::LOAD);
+    HttpAuthTestHandler none_handler(nullptr, TPrivilegeHier::GLOBAL, 
TPrivilegeType::NONE);
+
+    // When enable_all_http_auth=true, ALL types require authentication
+    // Test with valid auth - should pass for all types
+    {
+        auto evhttp_req = evhttp_request_new(nullptr, nullptr);
+        HttpRequest req(evhttp_req);
+        req._headers.emplace(HttpHeaders::AUTHORIZATION, "Basic cm9vdDo=");
+        req._params.emplace("table", "T");
+        EXPECT_EQ(none_handler.on_header(&req), 0);
+        evhttp_request_free(evhttp_req);
+    }
+
+    // Test without auth - should fail for all types
+    // When on_header returns -1, send_reply has been called internally,
+    // so we should NOT call evhttp_request_free (would cause double-free)
+    {
+        auto evhttp_req = evhttp_request_new(nullptr, nullptr);
+        HttpRequest req(evhttp_req);
+        // No auth header - should fail
+        EXPECT_EQ(none_handler.on_header(&req), -1);
+    }
+
+    {
+        auto evhttp_req = evhttp_request_new(nullptr, nullptr);
+        HttpRequest req(evhttp_req);
+        // No auth header - should fail
+        EXPECT_EQ(admin_handler.on_header(&req), -1);
+    }
+
+    {
+        auto evhttp_req = evhttp_request_new(nullptr, nullptr);
+        HttpRequest req(evhttp_req);
+        // No auth header - should fail
+        EXPECT_EQ(load_handler.on_header(&req), -1);
+    }
+}
+
 } // namespace doris
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/BaseController.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/BaseController.java
index 0e17f6d23ae..85000689ae9 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/BaseController.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/controller/BaseController.java
@@ -199,6 +199,7 @@ public class BaseController {
         public String remoteIp;
         public String password;
         public String cluster;
+        public UserIdentity userIdentity;  // Add this field for convenient 
parameter passing
 
         @Override
         public String toString() {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/BackendsAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/BackendsAction.java
index 368cc9acada..2564b38480c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/BackendsAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/BackendsAction.java
@@ -18,10 +18,7 @@
 package org.apache.doris.httpv2.rest;
 
 import org.apache.doris.catalog.Env;
-import org.apache.doris.catalog.InfoSchemaDb;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.system.Backend;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -70,7 +67,6 @@ public class BackendsAction extends RestBaseController {
     @RequestMapping(path = "/api/backends", method = {RequestMethod.GET})
     public Object getBackends(HttpServletRequest request, HttpServletResponse 
response) {
         executeCheckPassword(request, response);
-        checkDbAuth(ConnectContext.get().getCurrentUserIdentity(), 
InfoSchemaDb.DATABASE_NAME, PrivPredicate.SELECT);
 
         boolean needAlive = false;
         String isAlive = request.getParameter(IS_ALIVE);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/BootstrapFinishAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/BootstrapFinishAction.java
index 6ea4977aaec..1cd299803e5 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/BootstrapFinishAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/BootstrapFinishAction.java
@@ -20,6 +20,7 @@ package org.apache.doris.httpv2.rest;
 import org.apache.doris.catalog.Env;
 import org.apache.doris.common.Config;
 import org.apache.doris.common.Version;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 
 import com.google.common.base.Strings;
@@ -60,7 +61,8 @@ public class BootstrapFinishAction extends RestBaseController 
{
     @RequestMapping(path = "/api/bootstrap", method = RequestMethod.GET)
     public ResponseEntity execute(HttpServletRequest request, 
HttpServletResponse response) {
         if (Config.enable_all_http_auth) {
-            executeCheckPassword(request, response);
+            ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+            checkAdminAuth(authInfo.userIdentity);
         }
 
         boolean isReady = Env.getCurrentEnv().isReady();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckDecommissionAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckDecommissionAction.java
index fc7adb8fe64..b8ae4173e06 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckDecommissionAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckDecommissionAction.java
@@ -20,9 +20,9 @@ package org.apache.doris.httpv2.rest;
 import org.apache.doris.alter.SystemHandler;
 import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.DdlException;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.system.Backend;
 import org.apache.doris.system.SystemInfoService;
 import org.apache.doris.system.SystemInfoService.HostInfo;
@@ -57,8 +57,8 @@ public class CheckDecommissionAction extends 
RestBaseController {
     @RequestMapping(path = "/api/check_decommission", method = 
RequestMethod.GET)
     public Object execute(HttpServletRequest request, HttpServletResponse 
response) {
         //check user auth
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.OPERATOR);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkGlobalAuth(authInfo.userIdentity, PrivPredicate.OPERATOR);
 
         String hostPorts = request.getParameter(HOST_PORTS);
         if (Strings.isNullOrEmpty(hostPorts)) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckWalSizeAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckWalSizeAction.java
index 7eb7d11daa3..a1df019865a 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckWalSizeAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckWalSizeAction.java
@@ -20,9 +20,9 @@ package org.apache.doris.httpv2.rest;
 import org.apache.doris.catalog.Env;
 import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.DdlException;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.system.Backend;
 import org.apache.doris.system.SystemInfoService;
 import org.apache.doris.system.SystemInfoService.HostInfo;
@@ -57,8 +57,8 @@ public class CheckWalSizeAction extends RestBaseController {
     @RequestMapping(path = "/api/get_wal_size", method = RequestMethod.GET)
     public Object execute(HttpServletRequest request, HttpServletResponse 
response) {
         // check user auth
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.OPERATOR);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkGlobalAuth(authInfo.userIdentity, PrivPredicate.OPERATOR);
 
         String hostPorts = request.getParameter(HOST_PORTS);
         List<Backend> backends = new ArrayList<>();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ConnectionAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ConnectionAction.java
index f1d03846e65..4bcc31272f1 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ConnectionAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ConnectionAction.java
@@ -18,8 +18,8 @@
 package org.apache.doris.httpv2.rest;
 
 import org.apache.doris.common.util.DebugUtil;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
 import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.service.ExecuteEnv;
 
@@ -55,8 +55,8 @@ public class ConnectionAction extends RestBaseController {
 
     @RequestMapping(path = "/api/connection", method = RequestMethod.GET)
     protected Object connection(HttpServletRequest request, 
HttpServletResponse response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         String connStr = request.getParameter("connection_id");
         if (Strings.isNullOrEmpty(connStr)) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/DebugPointAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/DebugPointAction.java
index c78407bb977..4560d40dd14 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/DebugPointAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/DebugPointAction.java
@@ -20,9 +20,8 @@ package org.apache.doris.httpv2.rest;
 import org.apache.doris.common.Config;
 import org.apache.doris.common.util.DebugPointUtil;
 import org.apache.doris.common.util.DebugPointUtil.DebugPoint;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.base.Strings;
 import jakarta.servlet.http.HttpServletRequest;
@@ -48,8 +47,8 @@ public class DebugPointAction extends RestBaseController {
             return ResponseEntityBuilder.internalError(
                     "Disable debug points. please check 
Config.enable_debug_points");
         }
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
         if (Strings.isNullOrEmpty(name)) {
             return ResponseEntityBuilder.badRequest("Empty debug point name.");
         }
@@ -92,8 +91,8 @@ public class DebugPointAction extends RestBaseController {
             return ResponseEntityBuilder.internalError(
                     "Disable debug points. please check 
Config.enable_debug_points");
         }
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
         if (Strings.isNullOrEmpty(debugPoint)) {
             return ResponseEntityBuilder.badRequest("Empty debug point name.");
         }
@@ -107,8 +106,8 @@ public class DebugPointAction extends RestBaseController {
             return ResponseEntityBuilder.internalError(
                     "Disable debug points. please check 
Config.enable_debug_points");
         }
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
         DebugPointUtil.clearDebugPoints();
         return ResponseEntityBuilder.ok();
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ExtraBasepathAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ExtraBasepathAction.java
index 495f80dc8b4..8d2ae01e879 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ExtraBasepathAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ExtraBasepathAction.java
@@ -18,6 +18,7 @@
 package org.apache.doris.httpv2.rest;
 
 import org.apache.doris.common.Config;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 
 import com.google.common.base.Strings;
@@ -39,7 +40,8 @@ public class ExtraBasepathAction extends RestBaseController {
     @RequestMapping(path = "/api/basepath", method = RequestMethod.GET)
     public ResponseEntity execute(HttpServletRequest request, 
HttpServletResponse response) {
         if (Config.enable_all_http_auth) {
-            executeCheckPassword(request, response);
+            ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+            checkAdminAuth(authInfo.userIdentity);
         }
 
         BasepathResponse resp = new BasepathResponse();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/FeVersionInfoAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/FeVersionInfoAction.java
index bae9a25a093..ab298c4fcd9 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/FeVersionInfoAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/FeVersionInfoAction.java
@@ -18,9 +18,8 @@
 package org.apache.doris.httpv2.rest;
 
 import org.apache.doris.common.Version;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.collect.Maps;
 import jakarta.servlet.http.HttpServletRequest;
@@ -43,8 +42,8 @@ public class FeVersionInfoAction extends RestBaseController {
 
     @RequestMapping(path = "/api/fe_version_info", method = RequestMethod.GET)
     protected Object profile(HttpServletRequest request, HttpServletResponse 
response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         Map<String, Object> feVersionInfo = Maps.newHashMap();
         feVersionInfo.put("dorisBuildVersionPrefix", 
Version.DORIS_BUILD_VERSION_PREFIX);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/GetLogFileAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/GetLogFileAction.java
index bab2cf2c4e3..5a9d50c8ff2 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/GetLogFileAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/GetLogFileAction.java
@@ -18,9 +18,8 @@
 package org.apache.doris.httpv2.rest;
 
 import org.apache.doris.common.Config;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.base.Strings;
@@ -77,8 +76,8 @@ public class GetLogFileAction extends RestBaseController {
         if (!Config.enable_get_log_file_api) {
             return ResponseEntityBuilder.badRequest("feature disabled");
         }
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         String logType = request.getParameter("type");
         String logFile = request.getParameter("file");
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/GetSmallFileAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/GetSmallFileAction.java
index 54c47227177..3543c94cc27 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/GetSmallFileAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/GetSmallFileAction.java
@@ -20,9 +20,8 @@ package org.apache.doris.httpv2.rest;
 import org.apache.doris.catalog.Env;
 import org.apache.doris.common.Config;
 import org.apache.doris.common.util.SmallFileMgr;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.base.Strings;
 import jakarta.servlet.http.HttpServletRequest;
@@ -42,8 +41,8 @@ public class GetSmallFileAction extends RestBaseController {
     @RequestMapping(path = "/api/get_small_file", method = RequestMethod.GET)
     public Object execute(HttpServletRequest request, HttpServletResponse 
response) {
         if (Config.enable_all_http_auth) {
-            executeCheckPassword(request, response);
-            checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+            ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+            checkAdminAuth(authInfo.userIdentity);
         }
 
         String token = request.getParameter("token");
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/HealthAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/HealthAction.java
index 235eb4456f8..61a0ae78d73 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/HealthAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/HealthAction.java
@@ -19,7 +19,6 @@ package org.apache.doris.httpv2.rest;
 
 import org.apache.doris.DorisFE;
 import org.apache.doris.catalog.Env;
-import org.apache.doris.common.Config;
 import org.apache.doris.common.FeConstants;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 
@@ -39,10 +38,7 @@ public class HealthAction extends RestBaseController {
 
     @RequestMapping(path = "/api/health", method = RequestMethod.GET)
     public Object execute(HttpServletRequest request, HttpServletResponse 
response) {
-        if (Config.enable_all_http_auth) {
-            executeCheckPassword(request, response);
-        }
-
+        // Health endpoint is public - no authentication required
         if (!FeConstants.runningUnitTest && !DorisFE.isServerReady()) {
             return ResponseEntityBuilder.serviceUnavailable("Server is not 
ready");
         }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetaInfoAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetaInfoAction.java
index 81216fe2007..1ac0c7f5282 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetaInfoAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetaInfoAction.java
@@ -33,6 +33,7 @@ import org.apache.doris.common.proc.ProcResult;
 import org.apache.doris.common.proc.ProcService;
 import org.apache.doris.datasource.CatalogIf;
 import org.apache.doris.datasource.InternalCatalog;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 import org.apache.doris.httpv2.exception.BadRequestException;
 import org.apache.doris.mysql.privilege.PrivPredicate;
@@ -89,7 +90,10 @@ public class MetaInfoAction extends RestBaseController {
             @PathVariable(value = NS_KEY) String ns,
             HttpServletRequest request, HttpServletResponse response) {
         boolean checkAuth = Config.enable_all_http_auth ? true : false;
-        checkWithCookie(request, response, checkAuth);
+        ActionAuthorizationInfo authInfo = checkWithCookie(request, response, 
checkAuth);
+        if (Config.enable_all_http_auth) {
+            checkAdminAuth(authInfo.userIdentity);
+        }
 
         // use NS_KEY as catalog, but NS_KEY's default value is 
'default_cluster'.
         if (ns.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
@@ -138,7 +142,10 @@ public class MetaInfoAction extends RestBaseController {
             @PathVariable(value = NS_KEY) String ns, @PathVariable(value = 
DB_KEY) String dbName,
             HttpServletRequest request, HttpServletResponse response) {
         boolean checkAuth = Config.enable_all_http_auth ? true : false;
-        checkWithCookie(request, response, checkAuth);
+        ActionAuthorizationInfo authInfo = checkWithCookie(request, response, 
checkAuth);
+        if (Config.enable_all_http_auth) {
+            checkAdminAuth(authInfo.userIdentity);
+        }
 
         if (!ns.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
             return ResponseEntityBuilder.badRequest("Only support 
'default_cluster' now");
@@ -216,7 +223,10 @@ public class MetaInfoAction extends RestBaseController {
             @PathVariable(value = TABLE_KEY) String tblName,
             HttpServletRequest request, HttpServletResponse response) throws 
UserException {
         boolean checkAuth = Config.enable_all_http_auth ? true : false;
-        checkWithCookie(request, response, checkAuth);
+        ActionAuthorizationInfo authInfo = checkWithCookie(request, response, 
checkAuth);
+        if (Config.enable_all_http_auth) {
+            checkAdminAuth(authInfo.userIdentity);
+        }
 
         if (!ns.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
             return ResponseEntityBuilder.badRequest("Only support 
'default_cluster' now");
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetaReplayerCheckAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetaReplayerCheckAction.java
index fadf8ad105e..6fb97c21657 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetaReplayerCheckAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetaReplayerCheckAction.java
@@ -18,9 +18,8 @@
 package org.apache.doris.httpv2.rest;
 
 import org.apache.doris.catalog.Env;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
@@ -40,8 +39,8 @@ public class MetaReplayerCheckAction extends 
RestBaseController {
 
     @RequestMapping(path = "/api/_meta_replay_state", method = 
RequestMethod.GET)
     public Object execute(HttpServletRequest request, HttpServletResponse 
response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         Map<String, String> resultMap = 
Env.getCurrentEnv().getMetaReplayState().getInfo();
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetricsAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetricsAction.java
index 80eb824fcdf..8b812bda355 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetricsAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MetricsAction.java
@@ -17,7 +17,6 @@
 
 package org.apache.doris.httpv2.rest;
 
-import org.apache.doris.common.Config;
 import org.apache.doris.metric.JsonMetricVisitor;
 import org.apache.doris.metric.MetricRepo;
 import org.apache.doris.metric.MetricVisitor;
@@ -43,9 +42,7 @@ public class MetricsAction extends RestBaseController {
 
     @GetMapping(path = "/metrics")
     public void execute(HttpServletRequest request, HttpServletResponse 
response) {
-        if (Config.enable_all_http_auth) {
-            executeCheckPassword(request, response);
-        }
+        // Metrics endpoint is public - no authentication required
 
         String type = request.getParameter(TYPE_PARAM);
         MetricVisitor visitor = null;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MinidumpAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MinidumpAction.java
index 77f64256175..1d8979d6d97 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MinidumpAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/MinidumpAction.java
@@ -17,10 +17,9 @@
 
 package org.apache.doris.httpv2.rest;
 
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
 import org.apache.doris.nereids.minidump.MinidumpUtils;
-import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.base.Strings;
 import jakarta.servlet.http.HttpServletRequest;
@@ -44,8 +43,8 @@ public class MinidumpAction extends RestBaseController {
 
     @RequestMapping(path = "/api/minidump", method = RequestMethod.GET)
     protected Object minidump(HttpServletRequest request, HttpServletResponse 
response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         String queryId = request.getParameter("query_id");
         if (Strings.isNullOrEmpty(queryId)) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java
index 813612d68d0..f3a8d13d162 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java
@@ -18,9 +18,8 @@
 package org.apache.doris.httpv2.rest;
 
 import org.apache.doris.common.profile.ProfileManager;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.base.Strings;
 import com.google.common.collect.Maps;
@@ -44,8 +43,8 @@ public class ProfileAction extends RestBaseController {
 
     @RequestMapping(path = "/api/profile", method = RequestMethod.GET)
     protected Object profile(HttpServletRequest request, HttpServletResponse 
response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         String queryId = request.getParameter("query_id");
         if (Strings.isNullOrEmpty(queryId)) {
@@ -64,8 +63,8 @@ public class ProfileAction extends RestBaseController {
 
     @RequestMapping(path = "/api/profile/text", method = RequestMethod.GET)
     protected Object profileText(HttpServletRequest request, 
HttpServletResponse response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         String queryId = request.getParameter("query_id");
         if (Strings.isNullOrEmpty(queryId)) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/QueryStatsAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/QueryStatsAction.java
index 6907961bee9..a3b410300ec 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/QueryStatsAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/QueryStatsAction.java
@@ -19,9 +19,9 @@ package org.apache.doris.httpv2.rest;
 
 import org.apache.doris.catalog.Env;
 import org.apache.doris.datasource.InternalCatalog;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.system.SystemInfoService;
 
 import jakarta.servlet.http.HttpServletRequest;
@@ -55,8 +55,8 @@ public class QueryStatsAction extends RestBaseController {
         if (pretty && summary) {
             return ResponseEntityBuilder.badRequest("pretty and summary can 
not be true at the same time");
         }
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
         // use NS_KEY as catalog, but NS_KEY's default value is 
'default_cluster'.
         if (catalog.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
             catalog = InternalCatalog.INTERNAL_CATALOG_NAME;
@@ -82,8 +82,8 @@ public class QueryStatsAction extends RestBaseController {
         if (pretty && summary) {
             return ResponseEntityBuilder.badRequest("pretty and summary can 
not be true at the same time");
         }
-        executeCheckPassword(request, response);
-        checkDbAuth(ConnectContext.get().getCurrentUserIdentity(), database, 
PrivPredicate.SHOW);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkDbAuth(authInfo.userIdentity, database, PrivPredicate.SHOW);
         // use NS_KEY as catalog, but NS_KEY's default value is 
'default_cluster'.
         if (catalog.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
             catalog = InternalCatalog.INTERNAL_CATALOG_NAME;
@@ -109,8 +109,8 @@ public class QueryStatsAction extends RestBaseController {
         if (pretty && summary) {
             return ResponseEntityBuilder.badRequest("pretty and summary can 
not be true at the same time");
         }
-        executeCheckPassword(request, response);
-        checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), database, 
table, PrivPredicate.SHOW);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkTblAuth(authInfo.userIdentity, database, table, 
PrivPredicate.SHOW);
         // use NS_KEY as catalog, but NS_KEY's default value is 
'default_cluster'.
         if (catalog.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
             catalog = InternalCatalog.INTERNAL_CATALOG_NAME;
@@ -137,8 +137,8 @@ public class QueryStatsAction extends RestBaseController {
         if (pretty && summary) {
             return ResponseEntityBuilder.badRequest("pretty and summary can 
not be true at the same time");
         }
-        executeCheckPassword(request, response);
-        checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), database, 
table, PrivPredicate.SHOW);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkTblAuth(authInfo.userIdentity, database, table, 
PrivPredicate.SHOW);
         // use NS_KEY as catalog, but NS_KEY's default value is 
'default_cluster'.
         if (catalog.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
             catalog = InternalCatalog.INTERNAL_CATALOG_NAME;
@@ -159,8 +159,8 @@ public class QueryStatsAction extends RestBaseController {
     @RequestMapping(path = "/api/query_stats/{catalog}/{database}", method = 
RequestMethod.DELETE)
     protected Object clearQueryStatsFromDatabase(@PathVariable("catalog") 
String catalog,
             @PathVariable("database") String database, HttpServletRequest 
request, HttpServletResponse response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
         // use NS_KEY as catalog, but NS_KEY's default value is 
'default_cluster'.
         if (catalog.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
             catalog = InternalCatalog.INTERNAL_CATALOG_NAME;
@@ -173,8 +173,8 @@ public class QueryStatsAction extends RestBaseController {
     protected Object clearQueryStatsFromTable(@PathVariable("catalog") String 
catalog,
             @PathVariable("database") String database, @PathVariable("table") 
String table, HttpServletRequest request,
             HttpServletResponse response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
         // use NS_KEY as catalog, but NS_KEY's default value is 
'default_cluster'.
         if (catalog.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
             catalog = InternalCatalog.INTERNAL_CATALOG_NAME;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RestBaseController.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RestBaseController.java
index a350f1c5a58..78ac8ef31ef 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RestBaseController.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RestBaseController.java
@@ -76,6 +76,11 @@ public class RestBaseController extends BaseController {
         ActionAuthorizationInfo authInfo = getAuthorizationInfo(request);
         // check password
         UserIdentity currentUser = checkPassword(authInfo);
+
+        // Store UserIdentity in authInfo for convenient parameter passing
+        authInfo.userIdentity = currentUser;
+
+        // Set ConnectContext for backward compatibility
         ConnectContext ctx = new ConnectContext();
         ctx.setEnv(Env.getCurrentEnv());
         ctx.setRemoteIP(authInfo.remoteIp);
@@ -306,4 +311,17 @@ public class RestBaseController extends BaseController {
             return ResponseEntityBuilder.okWithCommonError(e.getMessage());
         }
     }
+
+    /**
+     * Check if admin privilege is required.
+     * When enable_all_http_auth is enabled, check if the user has admin 
privilege.
+     * If not authorized, throws UnauthorizedException.
+     *
+     * @param userIdentity The user identity to check
+     */
+    protected void checkAdminAuth(UserIdentity userIdentity) throws 
UnauthorizedException {
+        if (Config.enable_all_http_auth) {
+            checkGlobalAuth(userIdentity, 
org.apache.doris.mysql.privilege.PrivPredicate.ADMIN);
+        }
+    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RowCountAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RowCountAction.java
index 6ae3576f6b5..1e847477d9a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RowCountAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/RowCountAction.java
@@ -27,9 +27,8 @@ import org.apache.doris.catalog.Replica;
 import org.apache.doris.catalog.Table;
 import org.apache.doris.catalog.Tablet;
 import org.apache.doris.common.MetaNotFoundException;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.base.Strings;
 import com.google.common.collect.Maps;
@@ -50,8 +49,8 @@ public class RowCountAction extends RestBaseController {
 
     @RequestMapping(path = "/api/rowcount", method = RequestMethod.GET)
     protected Object rowcount(HttpServletRequest request, HttpServletResponse 
response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         String dbName = request.getParameter(DB_KEY);
         if (Strings.isNullOrEmpty(dbName)) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/SetConfigAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/SetConfigAction.java
index c41e3c574a1..d145e4e29e8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/SetConfigAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/SetConfigAction.java
@@ -22,8 +22,6 @@ import org.apache.doris.common.ConfigBase;
 import org.apache.doris.common.ConfigException;
 import org.apache.doris.common.DdlException;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.common.collect.Lists;
@@ -59,8 +57,8 @@ public class SetConfigAction extends RestBaseController {
 
     @RequestMapping(path = "/api/_set_config", method = RequestMethod.GET)
     protected Object set_config(HttpServletRequest request, 
HttpServletResponse response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         boolean needPersist = false;
         boolean resetPersist = true;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ShowAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ShowAction.java
index 1633e8514c0..d78582e5cd2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ShowAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ShowAction.java
@@ -24,7 +24,6 @@ import org.apache.doris.catalog.MysqlCompatibleDatabase;
 import org.apache.doris.catalog.OlapTable;
 import org.apache.doris.catalog.Table;
 import org.apache.doris.catalog.TableIf.TableType;
-import org.apache.doris.cluster.ClusterNamespace;
 import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.Config;
 import org.apache.doris.common.proc.ProcNodeInterface;
@@ -224,7 +223,7 @@ public class ShowAction extends RestBaseController {
         if (dbName != null) {
             String fullDbName = getFullDbName(dbName);
             if (!StringUtils.isEmpty(tableName) && 
Config.enable_all_http_auth) {
-                checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
fullDbName, tableName, PrivPredicate.SHOW);
+                checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
dbName, tableName, PrivPredicate.SHOW);
             }
 
             DatabaseIf db = 
Env.getCurrentInternalCatalog().getDbNullable(fullDbName);
@@ -232,7 +231,7 @@ public class ShowAction extends RestBaseController {
                 return ResponseEntityBuilder.okWithCommonError("database " + 
fullDbName + " not found.");
             }
             Map<String, Long> tablesEntry = getDataSizeOfTables(db, tableName, 
singleReplicaBool);
-            oneEntry.put(ClusterNamespace.getNameFromFullName(fullDbName), 
tablesEntry);
+            oneEntry.put(dbName, tablesEntry);
         } else {
             for (long dbId : Env.getCurrentInternalCatalog().getDbIds()) {
                 DatabaseIf db = 
Env.getCurrentInternalCatalog().getDbNullable(dbId);
@@ -246,7 +245,7 @@ public class ShowAction extends RestBaseController {
                     continue;
                 }
                 Map<String, Long> tablesEntry = getDataSizeOfTables(db, 
tableName, singleReplicaBool);
-                
oneEntry.put(ClusterNamespace.getNameFromFullName(db.getFullName()), 
tablesEntry);
+                oneEntry.put(db.getFullName(), tablesEntry);
             }
         }
         return ResponseEntityBuilder.ok(oneEntry);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StmtExecutionAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StmtExecutionAction.java
index 6ec305b9845..647a2ba7e08 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StmtExecutionAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StmtExecutionAction.java
@@ -24,7 +24,6 @@ import org.apache.doris.datasource.InternalCatalog;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 import org.apache.doris.httpv2.util.ExecutionResultSet;
 import org.apache.doris.httpv2.util.StatementSubmitter;
-import org.apache.doris.mysql.privilege.PrivPredicate;
 import org.apache.doris.nereids.NereidsPlanner;
 import org.apache.doris.nereids.StatementContext;
 import org.apache.doris.nereids.parser.NereidsParser;
@@ -93,7 +92,7 @@ public class StmtExecutionAction extends RestBaseController {
         ActionAuthorizationInfo authInfo = checkWithCookie(request, response, 
false);
         String fullDbName = getFullDbName(dbName);
         if (Config.enable_all_http_auth) {
-            checkDbAuth(ConnectContext.get().getCurrentUserIdentity(), 
fullDbName, PrivPredicate.ADMIN);
+            checkAdminAuth(authInfo.userIdentity);
         }
 
         if (ns.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StorageTypeCheckAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StorageTypeCheckAction.java
index 349dc24c2d1..2be69499590 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StorageTypeCheckAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StorageTypeCheckAction.java
@@ -23,9 +23,8 @@ import org.apache.doris.catalog.MaterializedIndexMeta;
 import org.apache.doris.catalog.OlapTable;
 import org.apache.doris.catalog.Table;
 import org.apache.doris.common.MetaNotFoundException;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.thrift.TStorageType;
 
 import com.google.common.base.Strings;
@@ -44,8 +43,8 @@ public class StorageTypeCheckAction extends 
RestBaseController {
 
     @RequestMapping(path = "/api/_check_storagetype", method = 
RequestMethod.GET)
     protected Object check_storagetype(HttpServletRequest request, 
HttpServletResponse response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         String dbName = request.getParameter(DB_KEY);
         if (Strings.isNullOrEmpty(dbName)) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java
index 87d1eedaa95..14e488763bf 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableQueryPlanAction.java
@@ -137,7 +137,7 @@ public class TableQueryPlanAction extends 
RestBaseController {
 
             String fullDbName = getFullDbName(dbName);
             // check privilege for select, otherwise return HTTP 401
-            checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
fullDbName, tblName, PrivPredicate.SELECT);
+            checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
dbName, tblName, PrivPredicate.SELECT);
             Table table;
             try {
                 Database db = 
Env.getCurrentInternalCatalog().getDbOrMetaException(fullDbName);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableRowCountAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableRowCountAction.java
index f753c872b62..3fdede06d3e 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableRowCountAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableRowCountAction.java
@@ -59,7 +59,7 @@ public class TableRowCountAction extends RestBaseController {
         try {
             String fullDbName = getFullDbName(dbName);
             // check privilege for select, otherwise return HTTP 401
-            checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
fullDbName, tblName, PrivPredicate.SELECT);
+            checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
dbName, tblName, PrivPredicate.SELECT);
             OlapTable olapTable;
             try {
                 Database db = 
Env.getCurrentInternalCatalog().getDbOrMetaException(fullDbName);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableSchemaAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableSchemaAction.java
index a3d766f1c6f..1da460877ac 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableSchemaAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/TableSchemaAction.java
@@ -113,7 +113,7 @@ public class TableSchemaAction extends RestBaseController {
         try {
             String fullDbName = getFullDbName(dbName);
             // check privilege for select, otherwise return 401 HTTP status
-            checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
catalogName, fullDbName, tblName,
+            checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
catalogName, dbName, tblName,
                     PrivPredicate.SELECT);
             TableIf table;
             try {
@@ -202,11 +202,12 @@ public class TableSchemaAction extends RestBaseController 
{
      */
     @RequestMapping(path = "/api/enable_light_schema_change/{" + DB_KEY
             + "}/{" + TABLE_KEY + "}", method = {RequestMethod.GET})
-    public Object columnChangeCanSync(
+     public Object columnChangeCanSync(
             @PathVariable(value = DB_KEY) String dbName,
             @PathVariable(value = TABLE_KEY) String tableName,
             HttpServletRequest request, HttpServletResponse response, 
@RequestBody String body) {
-        executeCheckPassword(request, response);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
         String fullDbName = getFullDbName(dbName);
         OlapTable table;
         try {
@@ -252,16 +253,16 @@ public class TableSchemaAction extends RestBaseController 
{
             @PathVariable(value = DB_KEY) final String dbName,
             @PathVariable(value = TABLE_KEY) final String tblName,
             HttpServletRequest request, HttpServletResponse response) {
-        executeCheckPassword(request, response);
-        GsonSchemaResponse gsonSchemaResponse = new GsonSchemaResponse();
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
         if (StringUtils.isBlank(catalogName)) {
             catalogName = InternalCatalog.INTERNAL_CATALOG_NAME;
         }
+        String fullDbName = getFullDbName(dbName);
+        checkTblAuth(authInfo.userIdentity, catalogName, fullDbName, tblName,
+                PrivPredicate.SELECT);
+        GsonSchemaResponse gsonSchemaResponse = new GsonSchemaResponse();
 
         try {
-            String fullDbName = getFullDbName(dbName);
-            checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
catalogName, fullDbName, tblName,
-                    PrivPredicate.SELECT);
             TableIf table;
             try {
                 CatalogIf catalog = StringUtils.isNotBlank(catalogName) ? 
Env.getCurrentEnv().getCatalogMgr()
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/UploadAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/UploadAction.java
index 941f1a6dcd6..fa00e4a5ab3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/UploadAction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/UploadAction.java
@@ -85,8 +85,7 @@ public class UploadAction extends RestBaseController {
             return ResponseEntityBuilder.badRequest("Only support 
'default_cluster' now");
         }
 
-        String fullDbName = getFullDbName(dbName);
-        checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
fullDbName, tblName, PrivPredicate.LOAD);
+        checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), dbName, 
tblName, PrivPredicate.LOAD);
 
         String columnSeparator = request.getParameter(PARAM_COLUMN_SEPARATOR);
         if (Strings.isNullOrEmpty(columnSeparator)) {
@@ -142,8 +141,7 @@ public class UploadAction extends RestBaseController {
             return ResponseEntityBuilder.badRequest("Only support 
'default_cluster' now");
         }
 
-        String fullDbName = getFullDbName(dbName);
-        checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
fullDbName, tblName, PrivPredicate.LOAD);
+        checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), dbName, 
tblName, PrivPredicate.LOAD);
 
         String fileIdStr = request.getParameter(PARAM_FILE_ID);
         if (Strings.isNullOrEmpty(fileIdStr)) {
@@ -198,8 +196,7 @@ public class UploadAction extends RestBaseController {
             return ResponseEntityBuilder.badRequest("Only support 
'default_cluster' now");
         }
 
-        String fullDbName = getFullDbName(dbName);
-        checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
fullDbName, tblName, PrivPredicate.LOAD);
+        checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), dbName, 
tblName, PrivPredicate.LOAD);
 
         String fileIdStr = request.getParameter(PARAM_FILE_ID);
         String fileUUIDStr = request.getParameter(PARAM_FILE_UUID);
@@ -242,8 +239,7 @@ public class UploadAction extends RestBaseController {
             return ResponseEntityBuilder.badRequest("Only support 
'default_cluster' now");
         }
 
-        String fullDbName = getFullDbName(dbName);
-        checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), 
fullDbName, tblName, PrivPredicate.LOAD);
+        checkTblAuth(ConnectContext.get().getCurrentUserIdentity(), dbName, 
tblName, PrivPredicate.LOAD);
 
         String fileIdStr = request.getParameter(PARAM_FILE_ID);
         if (Strings.isNullOrEmpty(fileIdStr)) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/ClusterAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/ClusterAction.java
index 995bc8080e8..391d7c85163 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/ClusterAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/ClusterAction.java
@@ -21,10 +21,9 @@ import org.apache.doris.catalog.Env;
 import org.apache.doris.cloud.system.CloudSystemInfoService;
 import org.apache.doris.common.Config;
 import org.apache.doris.common.util.NetUtils;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 import org.apache.doris.httpv2.rest.RestBaseController;
-import org.apache.doris.mysql.privilege.PrivPredicate;
-import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.system.Frontend;
 
 import com.google.common.collect.Maps;
@@ -60,8 +59,8 @@ public class ClusterAction extends RestBaseController {
     // }
     @RequestMapping(path = {"/cluster_info/conn_info", 
"/compute_group_info/conn_info"}, method = RequestMethod.GET)
     public Object clusterInfo(HttpServletRequest request, HttpServletResponse 
response) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         Map<String, List<String>> result = Maps.newHashMap();
         List<String> frontends = Env.getCurrentEnv().getFrontends(null)
@@ -110,8 +109,8 @@ public class ClusterAction extends RestBaseController {
             if (!Env.getCurrentEnv().isMaster()) {
                 ret = ResponseEntityBuilder.badRequest("this api just use in 
cloud master fe");
             } else {
-                executeCheckPassword(request, response);
-                checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+                ActionAuthorizationInfo authInfo = 
executeCheckPassword(request, response);
+                checkAdminAuth(authInfo.userIdentity);
 
                 // Key: cluster_name Value: be status
                 Map<String, List<BeClusterInfo>> result = Maps.newHashMap();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/NodeAction.java 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/NodeAction.java
index 4067864dc30..c9e51f4842b 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/NodeAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/NodeAction.java
@@ -30,6 +30,7 @@ import org.apache.doris.common.proc.ProcService;
 import org.apache.doris.common.util.NetUtils;
 import org.apache.doris.common.util.PropertyAnalyzer;
 import org.apache.doris.ha.FrontendNodeType;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 import org.apache.doris.httpv2.rest.RestBaseController;
 import org.apache.doris.httpv2.rest.SetConfigAction;
@@ -317,8 +318,8 @@ public class NodeAction extends RestBaseController {
     public Object configurationInfo(HttpServletRequest request, 
HttpServletResponse response,
             @RequestParam(value = "type") String type,
             @RequestBody(required = false) ConfigInfoRequestBody requestBody) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN_OR_NODE);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         initHttpExecutor();
 
@@ -490,8 +491,8 @@ public class NodeAction extends RestBaseController {
     @RequestMapping(path = "/set_config/fe", method = RequestMethod.POST)
     public Object setConfigFe(HttpServletRequest request, HttpServletResponse 
response,
             @RequestBody Map<String, SetConfigRequestBody> requestBody) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         List<Map<String, String>> failedTotal = Lists.newArrayList();
         List<NodeConfigs> nodeConfigList = parseSetConfigNodes(requestBody, 
failedTotal);
@@ -591,8 +592,8 @@ public class NodeAction extends RestBaseController {
     @RequestMapping(path = "/set_config/be", method = RequestMethod.POST)
     public Object setConfigBe(HttpServletRequest request, HttpServletResponse 
response,
             @RequestBody Map<String, SetConfigRequestBody> requestBody) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         List<Map<String, String>> failedTotal = Lists.newArrayList();
         List<NodeConfigs> nodeConfigList = parseSetConfigNodes(requestBody, 
failedTotal);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/QueryProfileAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/QueryProfileAction.java
index 7af8a05b648..5480858efbf 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/QueryProfileAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/manager/QueryProfileAction.java
@@ -29,6 +29,7 @@ import org.apache.doris.common.profile.ProfileManager;
 import org.apache.doris.common.profile.ProfileManager.ProfileElement;
 import org.apache.doris.common.profile.SummaryProfile;
 import org.apache.doris.common.util.NetUtils;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 import org.apache.doris.httpv2.rest.RestBaseController;
 import org.apache.doris.mysql.privilege.Auth;
@@ -459,8 +460,8 @@ public class QueryProfileAction extends RestBaseController {
     @RequestMapping(path = "/current_queries", method = RequestMethod.GET)
     public Object currentQueries(HttpServletRequest request, 
HttpServletResponse response,
             @RequestParam(value = IS_ALL_NODE_PARA, required = false, 
defaultValue = "true") boolean isAllNode) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         if (isAllNode) {
             // Get current queries from all FE
@@ -513,8 +514,8 @@ public class QueryProfileAction extends RestBaseController {
     public Object killQuery(HttpServletRequest request, HttpServletResponse 
response,
             @PathVariable("query_id") String queryId,
             @RequestParam(value = IS_ALL_NODE_PARA, required = false, 
defaultValue = "true") boolean isAllNode) {
-        executeCheckPassword(request, response);
-        checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), 
PrivPredicate.ADMIN);
+        ActionAuthorizationInfo authInfo = executeCheckPassword(request, 
response);
+        checkAdminAuth(authInfo.userIdentity);
 
         if (isAllNode) {
             // Get current queries from all FE
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/httpv2/rest/HttpApiAuthTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/httpv2/rest/HttpApiAuthTest.java
new file mode 100644
index 00000000000..b3c319fd46b
--- /dev/null
+++ b/fe/fe-core/src/test/java/org/apache/doris/httpv2/rest/HttpApiAuthTest.java
@@ -0,0 +1,158 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.httpv2.rest;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.common.Config;
+import 
org.apache.doris.httpv2.controller.BaseController.ActionAuthorizationInfo;
+import org.apache.doris.httpv2.exception.UnauthorizedException;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit tests for HTTP API authentication and authorization.
+ * Tests the new authentication framework:
+ * 1. ActionAuthorizationInfo.userIdentity field
+ * 2. RestBaseController.checkAdminAuth() method
+ * 3. enable_all_http_auth flag behavior
+ */
+public class HttpApiAuthTest {
+
+    private boolean originalEnableAllHttpAuth;
+
+    @Before
+    public void setUp() {
+        // Save original config
+        originalEnableAllHttpAuth = Config.enable_all_http_auth;
+    }
+
+    @After
+    public void tearDown() {
+        // Restore original config
+        Config.enable_all_http_auth = originalEnableAllHttpAuth;
+    }
+
+    @Test
+    public void testActionAuthorizationInfoHasUserIdentity() {
+        // Test that ActionAuthorizationInfo has userIdentity field
+        ActionAuthorizationInfo authInfo = new ActionAuthorizationInfo();
+        authInfo.fullUserName = "root";
+        authInfo.remoteIp = "127.0.0.1";
+        authInfo.password = "password";
+        authInfo.cluster = "default_cluster";
+
+        UserIdentity userIdentity = new UserIdentity("root", "%");
+        userIdentity.setIsAnalyzed();
+        authInfo.userIdentity = userIdentity;
+
+        Assert.assertNotNull("userIdentity field should exist", 
authInfo.userIdentity);
+        Assert.assertEquals("root", authInfo.userIdentity.getQualifiedUser());
+    }
+
+    @Test
+    public void testCheckAdminAuthWhenDisabled() {
+        // Test: when enable_all_http_auth=false, checkAdminAuth should not 
throw exception
+        Config.enable_all_http_auth = false;
+
+        TestRestController controller = new TestRestController();
+        UserIdentity normalUser = new UserIdentity("test_user", "%");
+        normalUser.setIsAnalyzed();
+
+        // Should not throw exception even for non-admin user when auth is 
disabled
+        try {
+            controller.checkAdminAuth(normalUser);
+            // Success - no exception thrown
+        } catch (UnauthorizedException e) {
+            Assert.fail("checkAdminAuth should not check privilege when 
enable_all_http_auth=false");
+        }
+    }
+
+    @Test
+    public void testCheckAdminAuthWithAdminUser() {
+        // Test: when enable_all_http_auth=true, admin user should pass 
checkAdminAuth
+        Config.enable_all_http_auth = true;
+
+        TestRestController controller = new TestRestController();
+        controller.setMockAdminResult(true);
+
+        UserIdentity adminUser = new UserIdentity("admin", "%");
+        adminUser.setIsAnalyzed();
+
+        try {
+            controller.checkAdminAuth(adminUser);
+            // Success - no exception thrown
+        } catch (UnauthorizedException e) {
+            Assert.fail("Admin user should pass checkAdminAuth: " + 
e.getMessage());
+        }
+    }
+
+    @Test
+    public void testCheckAdminAuthWithNormalUser() {
+        // Test: when enable_all_http_auth=true, normal user should fail 
checkAdminAuth
+        Config.enable_all_http_auth = true;
+
+        TestRestController controller = new TestRestController();
+        controller.setMockAdminResult(false);
+
+        UserIdentity normalUser = new UserIdentity("test_user", "%");
+        normalUser.setIsAnalyzed();
+
+        try {
+            controller.checkAdminAuth(normalUser);
+            Assert.fail("Normal user should not pass checkAdminAuth");
+        } catch (UnauthorizedException e) {
+            // Expected exception
+            Assert.assertTrue("Error message should mention privilege",
+                    e.getMessage().toLowerCase().contains("privilege")
+                            || 
e.getMessage().toLowerCase().contains("permission"));
+        }
+    }
+
+    @Test
+    public void testCheckAdminAuthMethodExists() {
+        // Test: checkAdminAuth(UserIdentity) method exists in 
RestBaseController
+        TestRestController controller = new TestRestController();
+
+        // This test passes if the method exists and compiles
+        Assert.assertNotNull("RestBaseController should have checkAdminAuth 
method", controller);
+    }
+
+    /**
+     * Test helper class that extends RestBaseController for testing
+     */
+    private static class TestRestController extends RestBaseController {
+        private boolean mockAdminResult = true;
+
+        public void setMockAdminResult(boolean isAdmin) {
+            this.mockAdminResult = isAdmin;
+        }
+
+        @Override
+        protected void checkGlobalAuth(UserIdentity currentUser, PrivPredicate 
predicate)
+                throws UnauthorizedException {
+            // Mock implementation for testing
+            if (predicate == PrivPredicate.ADMIN && !mockAdminResult) {
+                throw new UnauthorizedException("Access denied: need ADMIN 
privilege");
+            }
+        }
+    }
+}
diff --git a/regression-test/suites/auth/test_http_api_auth.groovy 
b/regression-test/suites/auth/test_http_api_auth.groovy
new file mode 100644
index 00000000000..e8c5d266608
--- /dev/null
+++ b/regression-test/suites/auth/test_http_api_auth.groovy
@@ -0,0 +1,216 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.apache.doris.regression.suite.ClusterOptions
+import groovy.json.JsonSlurper
+
+suite("test_http_api_auth", "docker") {
+    def options = new ClusterOptions()
+    options.cloudMode = false  // 存算一体模式
+
+    docker(options) {
+        // Get FE and BE HTTP addresses from cluster
+        def fe = cluster.getFeByIndex(1)
+        def be = cluster.getBeByIndex(1)
+        def feHost = fe.host + ":" + fe.httpPort
+        def beHost = be.host + ":" + be.httpPort
+
+        def jsonSlurper = new JsonSlurper()
+
+        // Helper to check JSON response code
+        def checkJsonCode = { bodyStr, expectedCode ->
+            def json = jsonSlurper.parseText(bodyStr)
+            assertEquals(expectedCode, json.code)
+        }
+
+        // ========== Setup ==========
+        sql """CREATE USER IF NOT EXISTS 'test_user'@'%' IDENTIFIED BY 
'test_password'"""
+        sql """GRANT SELECT_PRIV ON *.* TO 'test_user'@'%'"""
+
+        sql """CREATE USER IF NOT EXISTS 'admin_user'@'%' IDENTIFIED BY 
'admin_password'"""
+        sql """GRANT ADMIN_PRIV ON *.*.* TO 'admin_user'@'%'"""
+
+        // ========== Test Scenario 1: enable_all_http_auth = false ==========
+        sql """ADMIN SET FRONTEND CONFIG ("enable_all_http_auth" = "false")"""
+
+        // FE Health - no auth needed
+        httpTest {
+            endpoint feHost
+            uri "/api/health"
+            op "get"
+            check { code, body ->
+                assertEquals(200, code)
+                checkJsonCode(body, 0)  // code 0 means success
+            }
+        }
+
+        // FE Metrics - no auth needed
+        httpTest {
+            endpoint feHost
+            uri "/metrics"
+            op "get"
+            check { code, body ->
+                assertEquals(200, code)
+                assertTrue(body.contains("doris_"))
+            }
+        }
+
+        // BE Health - no auth needed
+        httpTest {
+            endpoint beHost
+            uri "/api/health"
+            op "get"
+            check { code, body ->
+                assertEquals(200, code)
+            }
+        }
+
+        // ========== Test Scenario 2: enable_all_http_auth = true - Public 
APIs ==========
+        // Health and Metrics endpoints are always public (no auth required)
+        sql """ADMIN SET FRONTEND CONFIG ("enable_all_http_auth" = "true")"""
+
+        // FE Health - still accessible without auth (public endpoint)
+        httpTest {
+            endpoint feHost
+            uri "/api/health"
+            op "get"
+            check { code, body ->
+                assertEquals(200, code)
+                checkJsonCode(body, 0)  // Health is always public
+            }
+        }
+
+        // FE Health - also works with auth
+        httpTest {
+            endpoint feHost
+            uri "/api/health"
+            op "get"
+            basicAuthorization "test_user", "test_password"
+            check { code, body ->
+                assertEquals(200, code)
+                checkJsonCode(body, 0)
+            }
+        }
+
+        // FE Metrics - still accessible without auth (public endpoint)
+        httpTest {
+            endpoint feHost
+            uri "/metrics"
+            op "get"
+            check { code, body ->
+                assertEquals(200, code)
+                assertTrue(body.contains("doris_"))  // Metrics is always 
public
+            }
+        }
+
+        // FE Metrics - also works with auth
+        httpTest {
+            endpoint feHost
+            uri "/metrics"
+            op "get"
+            basicAuthorization "test_user", "test_password"
+            check { code, body ->
+                assertEquals(200, code)
+                assertTrue(body.contains("doris_"))
+            }
+        }
+
+        // ========== Test Scenario 3: Admin APIs ==========
+
+        // FE Backends API - no auth returns 401 in JSON body
+        httpTest {
+            endpoint feHost
+            uri "/api/backends"
+            op "get"
+            check { code, body ->
+                assertEquals(200, code)
+                checkJsonCode(body, 401)
+            }
+        }
+
+        // FE Backends API - normal user returns 401 (Access denied, need 
Admin_priv)
+        // Note: The current implementation returns 401 for both 
authentication failure
+        // and authorization failure (insufficient privileges)
+        httpTest {
+            endpoint feHost
+            uri "/api/backends"
+            op "get"
+            basicAuthorization "test_user", "test_password"
+            check { code, body ->
+                assertEquals(200, code)
+                checkJsonCode(body, 401)  // Returns 401 with "Access denied; 
you need Admin_priv"
+            }
+        }
+
+        // FE Backends API - admin user succeeds
+        httpTest {
+            endpoint feHost
+            uri "/api/backends"
+            op "get"
+            basicAuthorization "admin_user", "admin_password"
+            check { code, body ->
+                assertEquals(200, code)
+                checkJsonCode(body, 0)
+            }
+        }
+
+        // ========== Test Scenario 4: Wrong Credentials on Admin APIs 
==========
+
+        // Test wrong password returns 401 on admin API
+        httpTest {
+            endpoint feHost
+            uri "/api/backends"
+            op "get"
+            basicAuthorization "admin_user", "wrong_password"
+            check { code, body ->
+                assertEquals(200, code)
+                checkJsonCode(body, 401)
+            }
+        }
+
+        // Test non-existent user returns 401 on admin API
+        httpTest {
+            endpoint feHost
+            uri "/api/backends"
+            op "get"
+            basicAuthorization "non_existent_user", "password"
+            check { code, body ->
+                assertEquals(200, code)
+                checkJsonCode(body, 401)
+            }
+        }
+
+        // Health endpoint works even with wrong credentials (public endpoint)
+        httpTest {
+            endpoint feHost
+            uri "/api/health"
+            op "get"
+            basicAuthorization "test_user", "wrong_password"
+            check { code, body ->
+                assertEquals(200, code)
+                checkJsonCode(body, 0)  // Health is always public
+            }
+        }
+
+        // ========== Cleanup ==========
+        sql """DROP USER IF EXISTS 'test_user'@'%'"""
+        sql """DROP USER IF EXISTS 'admin_user'@'%'"""
+
+        // Restore default config
+        sql """ADMIN SET FRONTEND CONFIG ("enable_all_http_auth" = "false")"""
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to