GRPC C++  1.22.0
credentials.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_CREDENTIALS_H
20 #define GRPCPP_SECURITY_CREDENTIALS_H
21 
23 
24 namespace grpc {
25 
31 
32 static inline std::shared_ptr<grpc_impl::ChannelCredentials>
33 GoogleDefaultCredentials() {
34  return ::grpc_impl::GoogleDefaultCredentials();
35 }
36 
37 static inline std::shared_ptr<ChannelCredentials> SslCredentials(
38  const SslCredentialsOptions& options) {
39  return ::grpc_impl::SslCredentials(options);
40 }
41 
42 static inline std::shared_ptr<grpc_impl::CallCredentials>
43 GoogleComputeEngineCredentials() {
44  return ::grpc_impl::GoogleComputeEngineCredentials();
45 }
46 
48 constexpr long kMaxAuthTokenLifetimeSecs =
50 
51 static inline std::shared_ptr<grpc_impl::CallCredentials>
52 ServiceAccountJWTAccessCredentials(
53  const grpc::string& json_key,
54  long token_lifetime_seconds = grpc::kMaxAuthTokenLifetimeSecs) {
55  return ::grpc_impl::ServiceAccountJWTAccessCredentials(
56  json_key, token_lifetime_seconds);
57 }
58 
59 static inline std::shared_ptr<grpc_impl::CallCredentials>
60 GoogleRefreshTokenCredentials(const grpc::string& json_refresh_token) {
61  return ::grpc_impl::GoogleRefreshTokenCredentials(json_refresh_token);
62 }
63 
64 static inline std::shared_ptr<grpc_impl::CallCredentials>
65 AccessTokenCredentials(const grpc::string& access_token) {
66  return ::grpc_impl::AccessTokenCredentials(access_token);
67 }
68 
69 static inline std::shared_ptr<grpc_impl::CallCredentials> GoogleIAMCredentials(
70  const grpc::string& authorization_token,
71  const grpc::string& authority_selector) {
72  return ::grpc_impl::GoogleIAMCredentials(authorization_token,
73  authority_selector);
74 }
75 
76 static inline std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
77  const std::shared_ptr<ChannelCredentials>& channel_creds,
78  const std::shared_ptr<CallCredentials>& call_creds) {
79  return ::grpc_impl::CompositeChannelCredentials(channel_creds, call_creds);
80 }
81 
82 static inline std::shared_ptr<grpc_impl::CallCredentials>
83 CompositeCallCredentials(const std::shared_ptr<CallCredentials>& creds1,
84  const std::shared_ptr<CallCredentials>& creds2) {
85  return ::grpc_impl::CompositeCallCredentials(creds1, creds2);
86 }
87 
88 static inline std::shared_ptr<grpc_impl::ChannelCredentials>
89 InsecureChannelCredentials() {
90  return ::grpc_impl::InsecureChannelCredentials();
91 }
92 
93 static inline std::shared_ptr<grpc_impl::ChannelCredentials>
94 CronetChannelCredentials(void* engine) {
95  return ::grpc_impl::CronetChannelCredentials(engine);
96 }
97 
99 
100 static inline std::shared_ptr<grpc_impl::CallCredentials>
101 MetadataCredentialsFromPlugin(
102  std::unique_ptr<MetadataCredentialsPlugin> plugin) {
103  return ::grpc_impl::MetadataCredentialsFromPlugin(std::move(plugin));
104 }
105 
106 namespace experimental {
107 
110 
111 static inline std::shared_ptr<grpc_impl::ChannelCredentials> AltsCredentials(
112  const AltsCredentialsOptions& options) {
113  return ::grpc_impl::experimental::AltsCredentials(options);
114 }
115 
116 static inline std::shared_ptr<grpc_impl::ChannelCredentials> LocalCredentials(
118  return ::grpc_impl::experimental::LocalCredentials(type);
119 }
120 
121 } // namespace experimental
122 } // namespace grpc
123 
124 #endif // GRPCPP_SECURITY_CREDENTIALS_H
::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin
Definition: credentials.h:98
std::string string
Definition: config.h:35
::grpc_impl::SecureChannelCredentials SecureChannelCredentials
Definition: credentials.h:30
Options used to build AltsCredentials.
Definition: credentials_impl.h:263
::grpc_impl::ChannelCredentials ChannelCredentials
Definition: credentials.h:26
::grpc_impl::experimental::AltsCredentialsOptions AltsCredentialsOptions
Definition: credentials.h:109
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
::grpc_impl::CallCredentials CallCredentials
Definition: credentials.h:27
::grpc_impl::SslCredentialsOptions SslCredentialsOptions
Definition: credentials.h:28
::grpc_impl::SecureCallCredentials SecureCallCredentials
Definition: credentials.h:29
constexpr long kMaxAuthTokenLifetimeSecs
Constant for maximum auth token lifetime.
Definition: credentials.h:48
grpc_local_connect_type
Type of local connections for which local channel/server credentials will be applied.
Definition: grpc_security_constants.h:112