3 // Copyright 2020 gRPC authors.
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 #ifndef GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_INSECURE_INSECURE_SECURITY_CONNECTOR_H
20 #define GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_INSECURE_INSECURE_SECURITY_CONNECTOR_H
22 #include <grpc/support/port_platform.h>
24 #include "src/core/lib/security/context/security_context.h"
25 #include "src/core/lib/security/credentials/credentials.h"
26 #include "src/core/lib/security/security_connector/security_connector.h"
30 extern const char kInsecureTransportSecurityType[];
32 class InsecureChannelSecurityConnector
33 : public grpc_channel_security_connector {
35 InsecureChannelSecurityConnector(
36 grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
37 grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds)
38 : grpc_channel_security_connector(/* url_scheme */ nullptr,
39 std::move(channel_creds),
40 std::move(request_metadata_creds)) {}
42 bool check_call_host(absl::string_view host, grpc_auth_context* auth_context,
43 grpc_closure* on_call_host_checked,
44 grpc_error** error) override;
46 void cancel_check_call_host(grpc_closure* on_call_host_checked,
47 grpc_error* error) override;
49 void add_handshakers(const grpc_channel_args* args,
50 grpc_pollset_set* /* interested_parties */,
51 grpc_core::HandshakeManager* handshake_manager) override;
53 void check_peer(tsi_peer peer, grpc_endpoint* ep,
54 grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
55 grpc_closure* on_peer_checked) override;
57 int cmp(const grpc_security_connector* other_sc) const override;
59 // Exposed for testing purposes only.
60 // Create an auth context which is necessary to pass the santiy check in
61 // client_auth_filter that verifies if the peer's auth context is obtained
62 // during handshakes. The auth context is only checked for its existence and
64 static RefCountedPtr<grpc_auth_context> MakeAuthContext();
67 } // namespace grpc_core
69 #endif /* GRPC_CORE_LIB_SECURITY_SECURITY_CONNECTOR_INSECURE_INSECURE_SECURITY_CONNECTOR_H \