diff --git a/BUILD b/BUILD index 9aff85c753b..34bd146cef3 100644 --- a/BUILD +++ b/BUILD @@ -1889,12 +1889,11 @@ grpc_cc_library( name = "grpc_mock_cel", hdrs = [ "src/core/lib/security/authorization/mock_cel/activation.h", - #"src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h", - #"src/core/lib/security/authorization/mock_cel/cel_expression.h", + "src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h", + "src/core/lib/security/authorization/mock_cel/cel_expression.h", "src/core/lib/security/authorization/mock_cel/cel_value.h", - #"src/core/lib/security/authorization/mock_cel/evaluator_core.h", - #"src/core/lib/security/authorization/mock_cel/flat_expr_builder.h", - #"src/core/lib/security/authorization/mock_cel/statusor.h", + "src/core/lib/security/authorization/mock_cel/evaluator_core.h", + "src/core/lib/security/authorization/mock_cel/flat_expr_builder.h", ], language = "c++", deps = [ diff --git a/BUILD.gn b/BUILD.gn index d530100358c..0acbd1b9048 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -984,7 +984,11 @@ config("grpc_config") { "src/core/lib/security/authorization/evaluate_args.cc", "src/core/lib/security/authorization/evaluate_args.h", "src/core/lib/security/authorization/mock_cel/activation.h", + "src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h", + "src/core/lib/security/authorization/mock_cel/cel_expression.h", "src/core/lib/security/authorization/mock_cel/cel_value.h", + "src/core/lib/security/authorization/mock_cel/evaluator_core.h", + "src/core/lib/security/authorization/mock_cel/flat_expr_builder.h", "src/core/lib/security/context/security_context.cc", "src/core/lib/security/context/security_context.h", "src/core/lib/security/credentials/alts/alts_credentials.cc", diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index df6bdeed97b..33466f4c119 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -755,7 +755,11 @@ libs: - src/core/lib/security/authorization/authorization_engine.h - src/core/lib/security/authorization/evaluate_args.h - src/core/lib/security/authorization/mock_cel/activation.h + - src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h + - src/core/lib/security/authorization/mock_cel/cel_expression.h - src/core/lib/security/authorization/mock_cel/cel_value.h + - src/core/lib/security/authorization/mock_cel/evaluator_core.h + - src/core/lib/security/authorization/mock_cel/flat_expr_builder.h - src/core/lib/security/context/security_context.h - src/core/lib/security/credentials/alts/alts_credentials.h - src/core/lib/security/credentials/alts/check_gcp_environment.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index da0642a77f0..2d2843a8809 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -600,7 +600,11 @@ Pod::Spec.new do |s| 'src/core/lib/security/authorization/authorization_engine.h', 'src/core/lib/security/authorization/evaluate_args.h', 'src/core/lib/security/authorization/mock_cel/activation.h', + 'src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h', + 'src/core/lib/security/authorization/mock_cel/cel_expression.h', 'src/core/lib/security/authorization/mock_cel/cel_value.h', + 'src/core/lib/security/authorization/mock_cel/evaluator_core.h', + 'src/core/lib/security/authorization/mock_cel/flat_expr_builder.h', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/alts/alts_credentials.h', 'src/core/lib/security/credentials/alts/check_gcp_environment.h', @@ -1204,7 +1208,11 @@ Pod::Spec.new do |s| 'src/core/lib/security/authorization/authorization_engine.h', 'src/core/lib/security/authorization/evaluate_args.h', 'src/core/lib/security/authorization/mock_cel/activation.h', + 'src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h', + 'src/core/lib/security/authorization/mock_cel/cel_expression.h', 'src/core/lib/security/authorization/mock_cel/cel_value.h', + 'src/core/lib/security/authorization/mock_cel/evaluator_core.h', + 'src/core/lib/security/authorization/mock_cel/flat_expr_builder.h', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/alts/alts_credentials.h', 'src/core/lib/security/credentials/alts/check_gcp_environment.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 6a36ba9b9a6..c99259b3577 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1040,7 +1040,11 @@ Pod::Spec.new do |s| 'src/core/lib/security/authorization/evaluate_args.cc', 'src/core/lib/security/authorization/evaluate_args.h', 'src/core/lib/security/authorization/mock_cel/activation.h', + 'src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h', + 'src/core/lib/security/authorization/mock_cel/cel_expression.h', 'src/core/lib/security/authorization/mock_cel/cel_value.h', + 'src/core/lib/security/authorization/mock_cel/evaluator_core.h', + 'src/core/lib/security/authorization/mock_cel/flat_expr_builder.h', 'src/core/lib/security/context/security_context.cc', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/alts/alts_credentials.cc', @@ -1733,7 +1737,11 @@ Pod::Spec.new do |s| 'src/core/lib/security/authorization/authorization_engine.h', 'src/core/lib/security/authorization/evaluate_args.h', 'src/core/lib/security/authorization/mock_cel/activation.h', + 'src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h', + 'src/core/lib/security/authorization/mock_cel/cel_expression.h', 'src/core/lib/security/authorization/mock_cel/cel_value.h', + 'src/core/lib/security/authorization/mock_cel/evaluator_core.h', + 'src/core/lib/security/authorization/mock_cel/flat_expr_builder.h', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/alts/alts_credentials.h', 'src/core/lib/security/credentials/alts/check_gcp_environment.h', diff --git a/grpc.gemspec b/grpc.gemspec index 3652846adf1..df687b72ec7 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -957,7 +957,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/authorization/evaluate_args.cc ) s.files += %w( src/core/lib/security/authorization/evaluate_args.h ) s.files += %w( src/core/lib/security/authorization/mock_cel/activation.h ) + s.files += %w( src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h ) + s.files += %w( src/core/lib/security/authorization/mock_cel/cel_expression.h ) s.files += %w( src/core/lib/security/authorization/mock_cel/cel_value.h ) + s.files += %w( src/core/lib/security/authorization/mock_cel/evaluator_core.h ) + s.files += %w( src/core/lib/security/authorization/mock_cel/flat_expr_builder.h ) s.files += %w( src/core/lib/security/context/security_context.cc ) s.files += %w( src/core/lib/security/context/security_context.h ) s.files += %w( src/core/lib/security/credentials/alts/alts_credentials.cc ) diff --git a/package.xml b/package.xml index 75a98409381..40997492ed6 100644 --- a/package.xml +++ b/package.xml @@ -937,7 +937,11 @@ + + + + diff --git a/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h b/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h index 3f22a28d609..74f2288ceb8 100644 --- a/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +++ b/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h @@ -33,7 +33,7 @@ struct InterpreterOptions { bool short_circuiting = true; }; -std::unique_ptr CreateCelExpressionBuilder( +inline std::unique_ptr CreateCelExpressionBuilder( const InterpreterOptions& options) { return absl::make_unique(); } diff --git a/src/core/lib/security/authorization/mock_cel/cel_expression.h b/src/core/lib/security/authorization/mock_cel/cel_expression.h index bdeba67a41d..34a31a6d525 100644 --- a/src/core/lib/security/authorization/mock_cel/cel_expression.h +++ b/src/core/lib/security/authorization/mock_cel/cel_expression.h @@ -20,10 +20,11 @@ #include #include +#include "absl/status/statusor.h" + #include "google/api/expr/v1alpha1/syntax.upb.h" #include "src/core/lib/security/authorization/mock_cel/activation.h" #include "src/core/lib/security/authorization/mock_cel/cel_value.h" -#include "src/core/lib/security/authorization/mock_cel/statusor.h" namespace grpc_core { namespace mock_cel { @@ -38,7 +39,7 @@ class CelExpression { // Evaluates expression and returns value. // activation contains bindings from parameter names to values - virtual StatusOr Evaluate( + virtual absl::StatusOr Evaluate( const BaseActivation& activation) const = 0; }; @@ -52,11 +53,11 @@ class CelExpressionBuilder { // Creates CelExpression object from AST tree. // expr specifies root of AST tree - virtual StatusOr> CreateExpression( + virtual absl::StatusOr> CreateExpression( const google_api_expr_v1alpha1_Expr* expr, const google_api_expr_v1alpha1_SourceInfo* source_info) const = 0; - virtual StatusOr> CreateExpression( + virtual absl::StatusOr> CreateExpression( const google_api_expr_v1alpha1_Expr* expr, const google_api_expr_v1alpha1_SourceInfo* source_info, std::vector* warnings) const = 0; diff --git a/src/core/lib/security/authorization/mock_cel/evaluator_core.h b/src/core/lib/security/authorization/mock_cel/evaluator_core.h index 7ddf495baf0..9aab0d2a8e6 100644 --- a/src/core/lib/security/authorization/mock_cel/evaluator_core.h +++ b/src/core/lib/security/authorization/mock_cel/evaluator_core.h @@ -21,11 +21,12 @@ #include #include +#include "absl/status/statusor.h" + #include "google/api/expr/v1alpha1/syntax.upb.h" #include "src/core/lib/security/authorization/mock_cel/activation.h" #include "src/core/lib/security/authorization/mock_cel/cel_expression.h" #include "src/core/lib/security/authorization/mock_cel/cel_value.h" -#include "src/core/lib/security/authorization/mock_cel/statusor.h" namespace grpc_core { namespace mock_cel { @@ -33,13 +34,11 @@ namespace mock_cel { // This is a temporary stub implementation of CEL APIs. // Once gRPC imports the CEL library, this file will be removed. -class ExpressionStep { +class ExecutionPath { public: - virtual ~ExpressionStep() = default; + ExecutionPath() = default; }; -using ExecutionPath = std::vector>; - // Implementation of the CelExpression that utilizes flattening // of the expression tree. class CelExpressionFlatImpl : public CelExpression { @@ -56,7 +55,8 @@ class CelExpressionFlatImpl : public CelExpression { bool enable_unknown_function_results = false) {} // Implementation of CelExpression evaluate method. - StatusOr Evaluate(const BaseActivation& activation) const override { + absl::StatusOr Evaluate( + const BaseActivation& activation) const override { return CelValue::CreateNull(); } }; diff --git a/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h b/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h index 86f5a239a32..255f0031624 100644 --- a/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +++ b/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h @@ -33,20 +33,21 @@ class FlatExprBuilder : public CelExpressionBuilder { public: FlatExprBuilder() = default; - cel_base::StatusOr> CreateExpression( - const google::api::expr::v1alpha1::Expr* expr, - const google::api::expr::v1alpha1::SourceInfo* source_info) - const override { + absl::StatusOr> CreateExpression( + const google_api_expr_v1alpha1_Expr* expr, + const google_api_expr_v1alpha1_SourceInfo* source_info) const override { ExecutionPath path; - return absl::make_unique(nullptr, path, 0); + return absl::make_unique(nullptr, path, 0, + std::set{}); } - cel_base::StatusOr> CreateExpression( - const google::api::expr::v1alpha1::Expr* expr, - const google::api::expr::v1alpha1::SourceInfo* source_info, + absl::StatusOr> CreateExpression( + const google_api_expr_v1alpha1_Expr* expr, + const google_api_expr_v1alpha1_SourceInfo* source_info, std::vector* warnings) const override { ExecutionPath path; - return absl::make_unique(nullptr, path, 0); + return absl::make_unique(nullptr, path, 0, + std::set{}); } }; diff --git a/src/core/lib/security/authorization/mock_cel/statusor.h b/src/core/lib/security/authorization/mock_cel/statusor.h deleted file mode 100644 index f97a8ec1229..00000000000 --- a/src/core/lib/security/authorization/mock_cel/statusor.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 gRPC authors. -// -// Licensed 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. - -#ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H -#define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H - -#include - -#include - -#include "absl/status/status.h" - -namespace grpc_core { -namespace mock_cel { - -// This is a temporary stub implementation of CEL APIs. -// Once gRPC imports the CEL library, this file will be removed. - -template -class ABSL_MUST_USE_RESULT StatusOr; - -template -class StatusOr { - public: - StatusOr() = default; - - StatusOr(const T& value) {} - - StatusOr(const absl::Status& status) {} - - StatusOr(absl::Status&& status) {} - - bool ok() const { return true; } -}; - -} // namespace mock_cel -} // namespace grpc_core - -#endif // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_STATUSOR_H \ No newline at end of file diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 90aadee82c6..791e2298921 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1889,7 +1889,11 @@ src/core/lib/security/authorization/authorization_engine.h \ src/core/lib/security/authorization/evaluate_args.cc \ src/core/lib/security/authorization/evaluate_args.h \ src/core/lib/security/authorization/mock_cel/activation.h \ +src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h \ +src/core/lib/security/authorization/mock_cel/cel_expression.h \ src/core/lib/security/authorization/mock_cel/cel_value.h \ +src/core/lib/security/authorization/mock_cel/evaluator_core.h \ +src/core/lib/security/authorization/mock_cel/flat_expr_builder.h \ src/core/lib/security/context/security_context.cc \ src/core/lib/security/context/security_context.h \ src/core/lib/security/credentials/alts/alts_credentials.cc \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 10de1cb9e2a..8abfd99d44a 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1731,7 +1731,11 @@ src/core/lib/security/authorization/authorization_engine.h \ src/core/lib/security/authorization/evaluate_args.cc \ src/core/lib/security/authorization/evaluate_args.h \ src/core/lib/security/authorization/mock_cel/activation.h \ +src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h \ +src/core/lib/security/authorization/mock_cel/cel_expression.h \ src/core/lib/security/authorization/mock_cel/cel_value.h \ +src/core/lib/security/authorization/mock_cel/evaluator_core.h \ +src/core/lib/security/authorization/mock_cel/flat_expr_builder.h \ src/core/lib/security/context/security_context.cc \ src/core/lib/security/context/security_context.h \ src/core/lib/security/credentials/alts/alts_credentials.cc \