3 * Copyright 2015 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 GRPCPP_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H
20 #define GRPCPP_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H
22 // IWYU pragma: private, include <grpcpp/security/auth_context.h>
27 #include <grpcpp/impl/codegen/config.h>
28 #include <grpcpp/impl/codegen/string_ref.h>
30 struct grpc_auth_context;
31 struct grpc_auth_property;
32 struct grpc_auth_property_iterator;
35 class SecureAuthContext;
37 typedef std::pair<string_ref, string_ref> AuthProperty;
39 class AuthPropertyIterator
40 : public std::iterator<std::input_iterator_tag, const AuthProperty> {
42 ~AuthPropertyIterator();
43 AuthPropertyIterator& operator++();
44 AuthPropertyIterator operator++(int);
45 bool operator==(const AuthPropertyIterator& rhs) const;
46 bool operator!=(const AuthPropertyIterator& rhs) const;
47 AuthProperty operator*();
50 AuthPropertyIterator();
51 AuthPropertyIterator(const grpc_auth_property* property,
52 const grpc_auth_property_iterator* iter);
55 friend class SecureAuthContext;
56 const grpc_auth_property* property_;
57 // The following items form a grpc_auth_property_iterator.
58 const grpc_auth_context* ctx_;
63 /// Class encapsulating the Authentication Information.
65 /// It includes the secure identity of the peer, the type of secure transport
66 /// used as well as any other properties required by the authorization layer.
69 virtual ~AuthContext() {}
71 /// Returns true if the peer is authenticated.
72 virtual bool IsPeerAuthenticated() const = 0;
76 /// It is, in general, comprised of one or more properties (in which case they
77 /// have the same name).
78 virtual std::vector<grpc::string_ref> GetPeerIdentity() const = 0;
79 virtual std::string GetPeerIdentityPropertyName() const = 0;
81 /// Returns all the property values with the given name.
82 virtual std::vector<grpc::string_ref> FindPropertyValues(
83 const std::string& name) const = 0;
85 /// Iteration over all the properties.
86 virtual AuthPropertyIterator begin() const = 0;
87 virtual AuthPropertyIterator end() const = 0;
89 /// Mutation functions: should only be used by an AuthMetadataProcessor.
90 virtual void AddProperty(const std::string& key, const string_ref& value) = 0;
91 virtual bool SetPeerIdentityPropertyName(const std::string& name) = 0;
96 #endif // GRPCPP_IMPL_CODEGEN_SECURITY_AUTH_CONTEXT_H