Skip to content

Commit

Permalink
[fix](auth)fix be enable http auth, some request link never return
Browse files Browse the repository at this point in the history
  • Loading branch information
hubgeter committed Dec 3, 2024
1 parent 6ce0208 commit f61ed66
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions be/src/http/http_handler_with_auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ HttpHandlerWithAuth::HttpHandlerWithAuth(ExecEnv* exec_env, TPrivilegeHier::type
: _exec_env(exec_env), _hier(hier), _type(type) {}

int HttpHandlerWithAuth::on_header(HttpRequest* req) {
//if u return value isn't 0,u should `send_reply`,Avoid requesting links that never return.
TCheckAuthRequest auth_request;
TCheckAuthResult auth_result;
AuthInfo auth_info;
Expand Down Expand Up @@ -83,13 +84,18 @@ int HttpHandlerWithAuth::on_header(HttpRequest* req) {

#ifndef BE_TEST
TNetworkAddress master_addr = _exec_env->cluster_info()->master_fe_addr;
if (master_addr.hostname.empty() || master_addr.port == 0) {
HttpChannel::send_reply(req, HttpStatus::BAD_REQUEST);
return -1;
}
{
auto status = ThriftRpcHelper::rpc<FrontendServiceClient>(
master_addr.hostname, master_addr.port,
[&auth_result, &auth_request](FrontendServiceConnection& client) {
client->checkAuth(auth_result, auth_request);
});
if (!status) {
HttpChannel::send_reply(req, HttpStatus::BAD_REQUEST);
return -1;
}
}
Expand All @@ -98,6 +104,7 @@ int HttpHandlerWithAuth::on_header(HttpRequest* req) {
auth_result.status.status_code = TStatusCode::type::OK;
auth_result.status.error_msgs.clear();
} else {
HttpChannel::send_reply(req, HttpStatus::BAD_REQUEST);
return -1;
}
#endif
Expand Down

0 comments on commit f61ed66

Please sign in to comment.