• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
16 #define GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
17 
18 #include <grpc/support/port_platform.h>
19 
20 #include <memory>
21 #include <set>
22 #include <string>
23 #include <vector>
24 
25 #include "absl/status/status.h"
26 #include "absl/status/statusor.h"
27 #include "google/api/expr/v1alpha1/syntax.upb.h"
28 #include "src/core/lib/security/authorization/mock_cel/cel_expression.h"
29 #include "src/core/lib/security/authorization/mock_cel/evaluator_core.h"
30 
31 namespace grpc_core {
32 namespace mock_cel {
33 
34 // This is a temporary stub implementation of CEL APIs.
35 // Once gRPC imports the CEL library, this file will be removed.
36 
37 // CelExpressionBuilder implementation.
38 // Builds instances of CelExpressionFlatImpl.
39 class FlatExprBuilder : public CelExpressionBuilder {
40  public:
41   FlatExprBuilder() = default;
42 
CreateExpression(const google_api_expr_v1alpha1_Expr * expr,const google_api_expr_v1alpha1_SourceInfo * source_info)43   absl::StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
44       const google_api_expr_v1alpha1_Expr* expr,
45       const google_api_expr_v1alpha1_SourceInfo* source_info) const override {
46     ExecutionPath path;
47     return std::make_unique<CelExpressionFlatImpl>(nullptr, path, 0,
48                                                    std::set<std::string>{});
49   }
50 
CreateExpression(const google_api_expr_v1alpha1_Expr * expr,const google_api_expr_v1alpha1_SourceInfo * source_info,std::vector<absl::Status> * warnings)51   absl::StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
52       const google_api_expr_v1alpha1_Expr* expr,
53       const google_api_expr_v1alpha1_SourceInfo* source_info,
54       std::vector<absl::Status>* warnings) const override {
55     ExecutionPath path;
56     return std::make_unique<CelExpressionFlatImpl>(nullptr, path, 0,
57                                                    std::set<std::string>{});
58   }
59 };
60 
61 }  // namespace mock_cel
62 }  // namespace grpc_core
63 
64 #endif  // GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
65