GRPC C++  1.66.0
auth_context.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2015 gRPC authors.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 //
18 
19 #ifndef GRPCPP_SECURITY_AUTH_CONTEXT_H
20 #define GRPCPP_SECURITY_AUTH_CONTEXT_H
21 
22 #include <iterator>
23 #include <vector>
24 
25 #include <grpcpp/support/config.h>
27 
28 struct grpc_auth_context;
29 struct grpc_auth_property;
31 
32 namespace grpc {
33 class SecureAuthContext;
34 
35 typedef std::pair<string_ref, string_ref> AuthProperty;
36 
38  public:
39  using iterator_category = std::forward_iterator_tag;
40  using value_type = const AuthProperty;
41  using pointer = void;
42  using reference = void;
43  using difference_type = std::ptrdiff_t;
44 
48  bool operator==(const AuthPropertyIterator& rhs) const;
49  bool operator!=(const AuthPropertyIterator& rhs) const;
51 
52  protected:
55  const grpc_auth_property_iterator* iter);
56 
57  private:
58  friend class SecureAuthContext;
59  const grpc_auth_property* property_;
60  // The following items form a grpc_auth_property_iterator.
61  const grpc_auth_context* ctx_;
62  size_t index_;
63  const char* name_;
64 };
65 
70 class AuthContext {
71  public:
72  virtual ~AuthContext() {}
73 
75  virtual bool IsPeerAuthenticated() const = 0;
76 
81  virtual std::vector<grpc::string_ref> GetPeerIdentity() const = 0;
82  virtual std::string GetPeerIdentityPropertyName() const = 0;
83 
85  virtual std::vector<grpc::string_ref> FindPropertyValues(
86  const std::string& name) const = 0;
87 
89  virtual AuthPropertyIterator begin() const = 0;
90  virtual AuthPropertyIterator end() const = 0;
91 
93  virtual void AddProperty(const std::string& key, const string_ref& value) = 0;
94  virtual bool SetPeerIdentityPropertyName(const std::string& name) = 0;
95 };
96 
97 } // namespace grpc
98 
99 #endif // GRPCPP_SECURITY_AUTH_CONTEXT_H
grpc::string_ref
This class is a non owning reference to a string.
Definition: string_ref.h:41
grpc::AuthContext::SetPeerIdentityPropertyName
virtual bool SetPeerIdentityPropertyName(const std::string &name)=0
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc::AuthContext::~AuthContext
virtual ~AuthContext()
Definition: auth_context.h:72
grpc::AuthPropertyIterator::~AuthPropertyIterator
~AuthPropertyIterator()
grpc::AuthPropertyIterator::operator==
bool operator==(const AuthPropertyIterator &rhs) const
grpc::AuthPropertyIterator::value_type
const AuthProperty value_type
Definition: auth_context.h:40
grpc::AuthPropertyIterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: auth_context.h:39
grpc::AuthPropertyIterator::difference_type
std::ptrdiff_t difference_type
Definition: auth_context.h:43
grpc_auth_property_iterator
Definition: grpc_security.h:37
grpc::AuthPropertyIterator::operator!=
bool operator!=(const AuthPropertyIterator &rhs) const
grpc::AuthContext::IsPeerAuthenticated
virtual bool IsPeerAuthenticated() const =0
Returns true if the peer is authenticated.
grpc::AuthContext
Class encapsulating the Authentication Information.
Definition: auth_context.h:70
grpc_auth_context
struct grpc_auth_context grpc_auth_context
Definition: credentials.h:39
grpc::AuthPropertyIterator::AuthPropertyIterator
AuthPropertyIterator()
grpc::AuthContext::AddProperty
virtual void AddProperty(const std::string &key, const string_ref &value)=0
Mutation functions: should only be used by an AuthMetadataProcessor.
grpc_auth_property
value, if not NULL, is guaranteed to be NULL terminated.
Definition: grpc_security.h:44
grpc::AuthPropertyIterator::reference
void reference
Definition: auth_context.h:42
grpc::AuthPropertyIterator::operator*
AuthProperty operator*()
grpc::AuthContext::FindPropertyValues
virtual std::vector< grpc::string_ref > FindPropertyValues(const std::string &name) const =0
Returns all the property values with the given name.
config.h
grpc::AuthContext::GetPeerIdentity
virtual std::vector< grpc::string_ref > GetPeerIdentity() const =0
A peer identity.
grpc::AuthPropertyIterator::operator++
AuthPropertyIterator & operator++()
grpc::AuthContext::end
virtual AuthPropertyIterator end() const =0
grpc::AuthContext::begin
virtual AuthPropertyIterator begin() const =0
Iteration over all the properties.
grpc::AuthProperty
std::pair< string_ref, string_ref > AuthProperty
Definition: auth_context.h:33
grpc::AuthPropertyIterator::SecureAuthContext
friend class SecureAuthContext
Definition: auth_context.h:58
grpc::AuthPropertyIterator::pointer
void pointer
Definition: auth_context.h:41
grpc::AuthContext::GetPeerIdentityPropertyName
virtual std::string GetPeerIdentityPropertyName() const =0
string_ref.h
grpc::AuthPropertyIterator
Definition: auth_context.h:37