Coverage Report

Created: 2026-06-05 20:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/service/arrow_flight/auth_server_middleware.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "service/arrow_flight/auth_server_middleware.h"
19
20
#include "service/arrow_flight/call_header_utils.h"
21
22
namespace doris {
23
namespace flight {
24
25
void NoOpHeaderAuthServerMiddleware::SendingHeaders(
26
0
        arrow::flight::AddCallHeaders* outgoing_headers) {
27
0
    outgoing_headers->AddHeader(kAuthHeader, std::string(kBearerPrefix) + kBearerDefaultToken);
28
0
}
29
30
arrow::Status NoOpHeaderAuthServerMiddlewareFactory::StartCall(
31
        const arrow::flight::CallInfo& info, const arrow::flight::ServerCallContext& context,
32
0
        std::shared_ptr<arrow::flight::ServerMiddleware>* middleware) {
33
0
    std::string username, password;
34
0
    ParseBasicHeader(context.incoming_headers(), username, password);
35
0
    *middleware = std::make_shared<NoOpHeaderAuthServerMiddleware>();
36
0
    return arrow::Status::OK();
37
0
}
38
39
void NoOpBearerAuthServerMiddleware::SendingHeaders(
40
0
        arrow::flight::AddCallHeaders* outgoing_headers) {
41
0
    std::string bearer_token =
42
0
            FindKeyValPrefixInCallHeaders(_incoming_headers, kAuthHeader, kBearerPrefix);
43
0
    *_is_valid = (bearer_token == std::string(kBearerDefaultToken));
44
0
}
45
46
arrow::Status NoOpBearerAuthServerMiddlewareFactory::StartCall(
47
        const arrow::flight::CallInfo& info, const arrow::flight::ServerCallContext& context,
48
0
        std::shared_ptr<arrow::flight::ServerMiddleware>* middleware) {
49
0
    *middleware = std::make_shared<NoOpBearerAuthServerMiddleware>(context.incoming_headers(),
50
0
                                                                   &_is_valid);
51
0
    return arrow::Status::OK();
52
0
}
53
54
} // namespace flight
55
} // namespace doris