• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright 2016 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H
20 #define GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H
21 
22 #include <grpc/support/port_platform.h>
23 
24 #include "src/core/lib/security/credentials/credentials.h"
25 
26 #define GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY "gcloud"
27 #define GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE \
28   "application_default_credentials.json"
29 
30 #ifdef GPR_WINDOWS
31 #define GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR "APPDATA"
32 #define GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX \
33   GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY    \
34   "/" GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE
35 #else
36 #define GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR "HOME"
37 #define GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX         \
38   ".config/" GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY \
39   "/" GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE
40 #endif
41 
42 typedef struct {
43   grpc_channel_credentials base;
44   grpc_channel_credentials* alts_creds;
45   grpc_channel_credentials* ssl_creds;
46 } grpc_google_default_channel_credentials;
47 
48 void grpc_flush_cached_google_default_credentials(void);
49 
50 namespace grpc_core {
51 namespace internal {
52 
53 typedef bool (*grpc_gce_tenancy_checker)(void);
54 
55 void set_gce_tenancy_checker_for_testing(grpc_gce_tenancy_checker checker);
56 
57 }  // namespace internal
58 }  // namespace grpc_core
59 
60 #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H \
61         */
62