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
22#include <grpcpp/security/credentials_impl.h>
23
24namespace grpc {
25
26typedef ::grpc_impl::ChannelCredentials ChannelCredentials;
27typedef ::grpc_impl::CallCredentials CallCredentials;
28typedef ::grpc_impl::SslCredentialsOptions SslCredentialsOptions;
29typedef ::grpc_impl::SecureCallCredentials SecureCallCredentials;
30typedef ::grpc_impl::SecureChannelCredentials SecureChannelCredentials;
31typedef ::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin;
32
33static inline std::shared_ptr<grpc_impl::ChannelCredentials>
34GoogleDefaultCredentials() {
35 return ::grpc_impl::GoogleDefaultCredentials();
36}
37
38static inline std::shared_ptr<ChannelCredentials> SslCredentials(
39 const SslCredentialsOptions& options) {
40 return ::grpc_impl::SslCredentials(options);
41}
42
43static inline std::shared_ptr<grpc_impl::CallCredentials>
44GoogleComputeEngineCredentials() {
45 return ::grpc_impl::GoogleComputeEngineCredentials();
46}
47
48/// Constant for maximum auth token lifetime.
49constexpr long kMaxAuthTokenLifetimeSecs =
50 ::grpc_impl::kMaxAuthTokenLifetimeSecs;
51
52static inline std::shared_ptr<grpc_impl::CallCredentials>
53ServiceAccountJWTAccessCredentials(
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
60static inline std::shared_ptr<grpc_impl::CallCredentials>
61GoogleRefreshTokenCredentials(const grpc::string& json_refresh_token) {
62 return ::grpc_impl::GoogleRefreshTokenCredentials(json_refresh_token);
63}
64
65static inline std::shared_ptr<grpc_impl::CallCredentials>
66AccessTokenCredentials(const grpc::string& access_token) {
67 return ::grpc_impl::AccessTokenCredentials(access_token);
68}
69
70static 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
77static 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
83static inline std::shared_ptr<grpc_impl::CallCredentials>
84CompositeCallCredentials(const std::shared_ptr<CallCredentials>& creds1,
85 const std::shared_ptr<CallCredentials>& creds2) {
86 return ::grpc_impl::CompositeCallCredentials(creds1, creds2);
87}
88
89static inline std::shared_ptr<grpc_impl::ChannelCredentials>
90InsecureChannelCredentials() {
91 return ::grpc_impl::InsecureChannelCredentials();
92}
93
94typedef ::grpc_impl::MetadataCredentialsPlugin MetadataCredentialsPlugin;
95
96static inline std::shared_ptr<grpc_impl::CallCredentials>
97MetadataCredentialsFromPlugin(
98 std::unique_ptr<MetadataCredentialsPlugin> plugin) {
99 return ::grpc_impl::MetadataCredentialsFromPlugin(plugin: std::move(plugin));
100}
101
102namespace experimental {
103
104typedef ::grpc_impl::experimental::StsCredentialsOptions StsCredentialsOptions;
105
106static inline grpc::Status StsCredentialsOptionsFromJson(
107 const grpc::string& json_string, StsCredentialsOptions* options) {
108 return ::grpc_impl::experimental::StsCredentialsOptionsFromJson(json_string,
109 options);
110}
111
112static inline grpc::Status StsCredentialsOptionsFromEnv(
113 StsCredentialsOptions* options) {
114 return grpc_impl::experimental::StsCredentialsOptionsFromEnv(options);
115}
116
117static inline std::shared_ptr<grpc_impl::CallCredentials> StsCredentials(
118 const StsCredentialsOptions& options) {
119 return grpc_impl::experimental::StsCredentials(options);
120}
121
122typedef ::grpc_impl::experimental::AltsCredentialsOptions
123 AltsCredentialsOptions;
124
125static inline std::shared_ptr<grpc_impl::ChannelCredentials> AltsCredentials(
126 const AltsCredentialsOptions& options) {
127 return ::grpc_impl::experimental::AltsCredentials(options);
128}
129
130static inline std::shared_ptr<grpc_impl::ChannelCredentials> LocalCredentials(
131 grpc_local_connect_type type) {
132 return ::grpc_impl::experimental::LocalCredentials(type);
133}
134
135static 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
144

source code of include/grpcpp/security/credentials.h