GRPC C++  1.30.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 
32 
33 static inline std::shared_ptr<grpc_impl::ChannelCredentials>
34 GoogleDefaultCredentials() {
35  return ::grpc_impl::GoogleDefaultCredentials();
36 }
37 
38 static inline std::shared_ptr<ChannelCredentials> SslCredentials(
39  const SslCredentialsOptions& options) {
40  return ::grpc_impl::SslCredentials(options);
41 }
42 
43 static inline std::shared_ptr<grpc_impl::CallCredentials>
44 GoogleComputeEngineCredentials() {
45  return ::grpc_impl::GoogleComputeEngineCredentials();
46 }
47 
49 constexpr long kMaxAuthTokenLifetimeSecs =
51 
52 static inline std::shared_ptr<grpc_impl::CallCredentials>
53 ServiceAccountJWTAccessCredentials(
54  const grpc::string& json_key,
55  long token_lifetime_seconds = grpc::kMaxAuthTokenLifetimeSecs) {
56  return ::grpc_impl::ServiceAccountJWTAccessCredentials(
57  json_key, token_lifetime_seconds);
58 }
59 
60 static inline std::shared_ptr<grpc_impl::CallCredentials>
61 GoogleRefreshTokenCredentials(const grpc::string& json_refresh_token) {
62  return ::grpc_impl::GoogleRefreshTokenCredentials(json_refresh_token);
63 }
64 
65 static inline std::shared_ptr<grpc_impl::CallCredentials>
66 AccessTokenCredentials(const grpc::string& access_token) {
67  return ::grpc_impl::AccessTokenCredentials(access_token);
68 }
69 
70 static inline std::shared_ptr<grpc_impl::CallCredentials> GoogleIAMCredentials(
71  const grpc::string& authorization_token,
72  const grpc::string& authority_selector) {
73  return ::grpc_impl::GoogleIAMCredentials(authorization_token,
74  authority_selector);
75 }
76 
77 static inline std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
78  const std::shared_ptr<ChannelCredentials>& channel_creds,
79  const std::shared_ptr<CallCredentials>& call_creds) {
80  return ::grpc_impl::CompositeChannelCredentials(channel_creds, call_creds);
81 }
82 
83 static inline std::shared_ptr<grpc_impl::CallCredentials>
84 CompositeCallCredentials(const std::shared_ptr<CallCredentials>& creds1,
85  const std::shared_ptr<CallCredentials>& creds2) {
86  return ::grpc_impl::CompositeCallCredentials(creds1, creds2);
87 }
88 
89 static inline std::shared_ptr<grpc_impl::ChannelCredentials>
90 InsecureChannelCredentials() {
91  return ::grpc_impl::InsecureChannelCredentials();
92 }
93 
95 
96 static inline std::shared_ptr<grpc_impl::CallCredentials>
97 MetadataCredentialsFromPlugin(
98  std::unique_ptr<MetadataCredentialsPlugin> plugin) {
99  return ::grpc_impl::MetadataCredentialsFromPlugin(std::move(plugin));
100 }
101 
102 namespace experimental {
103 
105 
106 static inline grpc::Status StsCredentialsOptionsFromJson(
107  const grpc::string& json_string, StsCredentialsOptions* options) {
108  return ::grpc_impl::experimental::StsCredentialsOptionsFromJson(json_string,
109  options);
110 }
111 
112 static inline grpc::Status StsCredentialsOptionsFromEnv(
113  StsCredentialsOptions* options) {
115 }
116 
117 static inline std::shared_ptr<grpc_impl::CallCredentials> StsCredentials(
118  const StsCredentialsOptions& options) {
120 }
121 
124 
125 static inline std::shared_ptr<grpc_impl::ChannelCredentials> AltsCredentials(
126  const AltsCredentialsOptions& options) {
127  return ::grpc_impl::experimental::AltsCredentials(options);
128 }
129 
130 static inline std::shared_ptr<grpc_impl::ChannelCredentials> LocalCredentials(
132  return ::grpc_impl::experimental::LocalCredentials(type);
133 }
134 
135 static inline std::shared_ptr<grpc_impl::ChannelCredentials> TlsCredentials(
136  const ::grpc_impl::experimental::TlsCredentialsOptions& options) {
137  return ::grpc_impl::experimental::TlsCredentials(options);
138 }
139 
140 } // namespace experimental
141 } // namespace grpc
142 
143 #endif // GRPCPP_SECURITY_CREDENTIALS_H
grpc_impl::experimental::StsCredentials
std::shared_ptr< CallCredentials > StsCredentials(const StsCredentialsOptions &options)
grpc
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
grpc::MetadataCredentialsPlugin
::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin
Definition: credentials.h:31
grpc::ChannelCredentials
::grpc_impl::ChannelCredentials ChannelCredentials
Definition: credentials.h:26
grpc::SecureCallCredentials
::grpc_impl::SecureCallCredentials SecureCallCredentials
Definition: credentials.h:29
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:31
grpc_impl::experimental::StsCredentialsOptionsFromEnv
grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions *options)
Creates STS credentials options from the $STS_CREDENTIALS environment variable.
grpc_impl::experimental::StsCredentialsOptions
Options for creating STS Oauth Token Exchange credentials following the IETF draft https://tools....
Definition: credentials_impl.h:272
grpc::experimental::AltsCredentialsOptions
::grpc_impl::experimental::AltsCredentialsOptions AltsCredentialsOptions
Definition: credentials.h:123
grpc::experimental::StsCredentialsOptions
::grpc_impl::experimental::StsCredentialsOptions StsCredentialsOptions
Definition: credentials.h:104
grpc_impl::experimental::AltsCredentialsOptions
Options used to build AltsCredentials.
Definition: credentials_impl.h:336
grpc::SecureChannelCredentials
::grpc_impl::SecureChannelCredentials SecureChannelCredentials
Definition: credentials.h:30
credentials_impl.h
grpc::CallCredentials
::grpc_impl::CallCredentials CallCredentials
Definition: credentials.h:27
grpc::string
std::string string
Definition: config.h:35
grpc::kMaxAuthTokenLifetimeSecs
constexpr long kMaxAuthTokenLifetimeSecs
Constant for maximum auth token lifetime.
Definition: credentials.h:49
grpc::SslCredentialsOptions
::grpc_impl::SslCredentialsOptions SslCredentialsOptions
Definition: credentials.h:28
grpc_local_connect_type
grpc_local_connect_type
Type of local connections for which local channel/server credentials will be applied.
Definition: grpc_security_constants.h:140