1 // Copyright 2021 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_AUTHORIZATION_POLICY_PROVIDER_H 16 #define GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_AUTHORIZATION_POLICY_PROVIDER_H 17 18 #include <grpc/grpc_security.h> 19 #include <grpc/impl/channel_arg_names.h> 20 #include <grpc/support/port_platform.h> 21 22 #include "absl/strings/string_view.h" 23 #include "src/core/lib/security/authorization/authorization_engine.h" 24 #include "src/core/util/dual_ref_counted.h" 25 #include "src/core/util/ref_counted_ptr.h" 26 #include "src/core/util/useful.h" 27 28 struct grpc_authorization_policy_provider 29 : public grpc_core::DualRefCounted<grpc_authorization_policy_provider> { 30 public: ChannelArgNamegrpc_authorization_policy_provider31 static absl::string_view ChannelArgName() { 32 return GRPC_ARG_AUTHORIZATION_POLICY_PROVIDER; 33 } ChannelArgsComparegrpc_authorization_policy_provider34 static int ChannelArgsCompare(const grpc_authorization_policy_provider* a, 35 const grpc_authorization_policy_provider* b) { 36 return QsortCompare(a, b); 37 } 38 struct AuthorizationEngines { 39 grpc_core::RefCountedPtr<grpc_core::AuthorizationEngine> allow_engine; 40 grpc_core::RefCountedPtr<grpc_core::AuthorizationEngine> deny_engine; 41 }; 42 virtual AuthorizationEngines engines() = 0; 43 }; 44 45 #endif // GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_AUTHORIZATION_POLICY_PROVIDER_H 46