1 | import { BaseExternalAccountClient, BaseExternalAccountClientOptions } from './baseexternalclient';
|
2 | import { AuthClientOptions } from './authclient';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | export interface PluggableAuthClientOptions extends BaseExternalAccountClientOptions {
|
24 | credential_source: {
|
25 | executable: {
|
26 | |
27 |
|
28 |
|
29 | command: string;
|
30 | |
31 |
|
32 |
|
33 |
|
34 | timeout_millis?: number;
|
35 | |
36 |
|
37 |
|
38 |
|
39 | output_file?: string;
|
40 | };
|
41 | };
|
42 | }
|
43 |
|
44 |
|
45 |
|
46 | export declare class ExecutableError extends Error {
|
47 | |
48 |
|
49 |
|
50 | readonly code: string;
|
51 | constructor(message: string, code: string);
|
52 | }
|
53 | /**
|
54 | * PluggableAuthClient enables the exchange of workload identity pool external credentials for
|
55 | * Google access tokens by retrieving 3rd party tokens through a user supplied executable. These
|
56 | * scripts/executables are completely independent of the Google Cloud Auth libraries. These
|
57 | * credentials plug into ADC and will call the specified executable to retrieve the 3rd party token
|
58 | * to be exchanged for a Google access token.
|
59 | *
|
60 | * <p>To use these credentials, the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment variable
|
61 | * must be set to '1'. This is for security reasons.
|
62 | *
|
63 | * <p>Both OIDC and SAML are supported. The executable must adhere to a specific response format
|
64 | * defined below.
|
65 | *
|
66 | * <p>The executable must print out the 3rd party token to STDOUT in JSON format. When an
|
67 | * output_file is specified in the credential configuration, the executable must also handle writing the
|
68 | * JSON response to this file.
|
69 | *
|
70 | * <pre>
|
71 | * OIDC response sample:
|
72 | * {
|
73 | * "version": 1,
|
74 | * "success": true,
|
75 | * "token_type": "urn:ietf:params:oauth:token-type:id_token",
|
76 | * "id_token": "HEADER.PAYLOAD.SIGNATURE",
|
77 | * "expiration_time": 1620433341
|
78 | * }
|
79 | *
|
80 | * SAML2 response sample:
|
81 | * {
|
82 | * "version": 1,
|
83 | * "success": true,
|
84 | * "token_type": "urn:ietf:params:oauth:token-type:saml2",
|
85 | * "saml_response": "...",
|
86 | * "expiration_time": 1620433341
|
87 | * }
|
88 | *
|
89 | * Error response sample:
|
90 | * {
|
91 | * "version": 1,
|
92 | * "success": false,
|
93 | * "code": "401",
|
94 | * "message": "Error message."
|
95 | * }
|
96 | * </pre>
|
97 | *
|
98 | * <p>The "expiration_time" field in the JSON response is only required for successful
|
99 | * responses when an output file was specified in the credential configuration
|
100 | *
|
101 | * <p>The auth libraries will populate certain environment variables that will be accessible by the
|
102 | * executable, such as: GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE, GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE,
|
103 | * GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE, GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL, and
|
104 | * GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE.
|
105 | *
|
106 | * <p>Please see this repositories README for a complete executable request/response specification.
|
107 | */
|
108 | export declare class PluggableAuthClient extends BaseExternalAccountClient {
|
109 | |
110 |
|
111 |
|
112 | private readonly command;
|
113 | |
114 |
|
115 |
|
116 |
|
117 | private readonly timeoutMillis;
|
118 | |
119 |
|
120 |
|
121 | private readonly outputFile?;
|
122 | |
123 |
|
124 |
|
125 | private readonly handler;
|
126 | |
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | constructor(options: PluggableAuthClientOptions, additionalOptions?: AuthClientOptions);
|
138 | /**
|
139 | * Triggered when an external subject token is needed to be exchanged for a
|
140 | * GCP access token via GCP STS endpoint.
|
141 | * This uses the `options.credential_source` object to figure out how
|
142 | * to retrieve the token using the current environment. In this case,
|
143 | * this calls a user provided executable which returns the subject token.
|
144 | * The logic is summarized as:
|
145 | * 1. Validated that the executable is allowed to run. The
|
146 | * GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment must be set to
|
147 | * 1 for security reasons.
|
148 | * 2. If an output file is specified by the user, check the file location
|
149 | * for a response. If the file exists and contains a valid response,
|
150 | * return the subject token from the file.
|
151 | * 3. Call the provided executable and return response.
|
152 | * @return A promise that resolves with the external subject token.
|
153 | */
|
154 | retrieveSubjectToken(): Promise<string>;
|
155 | }
|