Skip to content

Commit 812b78d

Browse files
committed
Merge remote-tracking branch 'remotes/origin/main' into add-debug-logging
2 parents 3a35055 + f23e807 commit 812b78d

File tree

92 files changed

+1840
-1764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1840
-1764
lines changed

.github/.OwlBot.lock.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest
16-
digest: sha256:609822e3c09b7a1bd90b99655904609f162cc15acb4704f1edf778284c36f429
17-
# created: 2024-10-01T19:34:30.797530443Z
16+
digest: sha256:0d39e59663287ae929c1d4ccf8ebf7cef9946826c9b86eda7e85d8d752dbb584
17+
# created: 2024-11-21T22:39:44.342569463Z

.github/release-trigger.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
enabled: true
2+
multiScmName: google-auth-library-nodejs

.github/sync-repo-settings.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ branchProtectionRules:
88
- "ci/kokoro: Samples test"
99
- "ci/kokoro: System test"
1010
- lint
11-
- test (14)
12-
- test (16)
1311
- test (18)
12+
- test (20)
13+
- test (22)
1414
- cla/google
1515
- windows
1616
- OwlBot Post Processor

.github/workflows/ci.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
node: [14, 16, 18, 20]
12+
node: [18, 20, 22]
1313
steps:
14-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
14+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
1515
- uses: actions/setup-node@v4
1616
with:
1717
node-version: ${{ matrix.node }}
@@ -29,21 +29,21 @@ jobs:
2929
windows:
3030
runs-on: windows-latest
3131
steps:
32-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
32+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
3333
- uses: actions/setup-node@v4
3434
with:
35-
node-version: 14
35+
node-version: 18
3636
- run: npm install
3737
- run: npm test
3838
env:
3939
MOCHA_THROW_DEPRECATION: false
4040
lint:
4141
runs-on: ubuntu-latest
4242
steps:
43-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
43+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
4444
- uses: actions/setup-node@v4
4545
with:
46-
node-version: 14
46+
node-version: 18
4747
- run: npm install
4848
- run: npm run lint
4949
docs:

.kokoro/common.cfg

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/continuous/node14/common.cfg

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/continuous/node18/common.cfg

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/continuous/node18/lint.cfg

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/continuous/node18/samples-test.cfg

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/continuous/node18/system-test.cfg

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/continuous/node18/test.cfg

Whitespace-only changes.

.kokoro/presubmit/node14/common.cfg

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/presubmit/node18/common.cfg

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/presubmit/node18/samples-test.cfg

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/presubmit/node18/system-test.cfg

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/presubmit/node18/test.cfg

Whitespace-only changes.

.kokoro/release/docs-devsite.cfg

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/release/docs.cfg

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/release/docs.sh

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/release/publish.cfg

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/samples-test.sh

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/system-test.sh

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/test.bat

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/test.sh

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.kokoro/trampoline_v2.sh

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.readme-partials.yaml

+17-22
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,12 @@ body: |-
1313
- [Downscoped Client](#downscoped-client) - Use Downscoped Client with Credential Access Boundary to generate a short-lived credential with downscoped, restricted IAM permissions that can use for Cloud Storage.
1414
1515
## Application Default Credentials
16-
This library provides an implementation of [Application Default Credentials](https://cloud.google.com/docs/authentication/getting-started) for Node.js. The [Application Default Credentials](https://cloud.google.com/docs/authentication/getting-started) provide a simple way to get authorization credentials for use in calling Google APIs.
1716
18-
They are best suited for cases when the call needs to have the same identity and authorization level for the application independent of the user. This is the recommended approach to authorize calls to Cloud APIs, particularly when you're building an application that uses Google Cloud Platform.
17+
This library provides an implementation of [Application Default Credentials (ADC)](https://cloud.google.com/docs/authentication/application-default-credentials) for Node.js. ADC provides a simple way to get credentials for use in calling Google APIs. How you [set up ADC](https://cloud.google.com/docs/authentication/provide-credentials-adc) depends on the environment where your code is running.
1918
20-
Application Default Credentials also support workload identity federation to access Google Cloud resources from non-Google Cloud platforms including Amazon Web Services (AWS), Microsoft Azure or any identity provider that supports OpenID Connect (OIDC). Workload identity federation is recommended for non-Google Cloud environments as it avoids the need to download, manage and store service account private keys locally, see: [Workload Identity Federation](#workload-identity-federation).
19+
ADC is best suited for cases when the call needs to have the same identity and authorization level for the application independent of the user. This is the recommended approach to authorize calls to Cloud APIs, particularly when you're building an application that uses Google Cloud Platform.
2120
22-
#### Download your Service Account Credentials JSON file
23-
24-
To use Application Default Credentials, You first need to download a set of JSON credentials for your project. Go to **APIs & Auth** > **Credentials** in the [Google Developers Console](https://console.cloud.google.com/) and select **Service account** from the **Add credentials** dropdown.
25-
26-
> This file is your *only copy* of these credentials. It should never be
27-
> committed with your source code, and should be stored securely.
28-
29-
Once downloaded, store the path to this file in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
21+
Application Default Credentials also supports Workload Identity Federation to access Google Cloud resources from non-Google Cloud platforms including Amazon Web Services (AWS), Microsoft Azure or any identity provider that supports OpenID Connect (OIDC). Workload Identity Federation is recommended for non-Google Cloud environments as it avoids the need to download, manage and store service account private keys locally, see: [Workload Identity Federation](#workload-identity-federation).
3022
3123
#### Enable the API you want to use
3224
@@ -64,7 +56,7 @@ body: |-
6456
6557
## OAuth2
6658
67-
This library comes with an [OAuth2](https://developers.google.com/identity/protocols/OAuth2) client that allows you to retrieve an access token and refreshes the token and retry the request seamlessly if you also provide an `expiry_date` and the token is expired. The basics of Google's OAuth2 implementation is explained on [Google Authorization and Authentication documentation](https://developers.google.com/accounts/docs/OAuth2Login).
59+
This library comes with an [OAuth2](https://developers.google.com/identity/protocols/OAuth2) client that allows you to retrieve an access token and refreshes the token and retry the request seamlessly if you also provide an `expiry_date` and the token is expired. The basics of Google's OAuth2 implementation is explained on [Google authorization and Authentication documentation](https://developers.google.com/accounts/docs/OAuth2Login).
6860
6961
In the following examples, you may need a `CLIENT_ID`, `CLIENT_SECRET` and `REDIRECT_URL`. You can find these pieces of information by going to the [Developer Console](https://console.cloud.google.com/), clicking your project > APIs & auth > credentials.
7062
@@ -111,11 +103,11 @@ body: |-
111103
return new Promise((resolve, reject) => {
112104
// create an oAuth client to authorize the API call. Secrets are kept in a `keys.json` file,
113105
// which should be downloaded from the Google Developers Console.
114-
const oAuth2Client = new OAuth2Client(
115-
keys.web.client_id,
116-
keys.web.client_secret,
117-
keys.web.redirect_uris[0]
118-
);
106+
const oAuth2Client = new OAuth2Client({
107+
clientId: keys.web.client_id,
108+
clientSecret: keys.web.client_secret,
109+
redirectUri: keys.web.redirect_uris[0]
110+
});
119111
120112
// Generate the url that will be used for the consent dialog.
121113
const authorizeUrl = oAuth2Client.generateAuthUrl({
@@ -308,6 +300,8 @@ body: |-
308300
main().catch(console.error);
309301
```
310302
303+
**Important**: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information, refer to [Validate credential configurations from external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
304+
311305
#### Using a Proxy
312306
You can set the `HTTPS_PROXY` or `https_proxy` environment variables to proxy HTTPS requests. When `HTTPS_PROXY` or `https_proxy` are set, they will be used to proxy SSL requests that do not have an explicit proxy configuration option present.
313307
@@ -434,6 +428,7 @@ body: |-
434428
audience: '//iam.googleapis.com/projects/$PROJECT_NUMBER/locations/global/workloadIdentityPools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID', // Set the GCP audience.
435429
subject_token_type: 'urn:ietf:params:aws:token-type:aws4_request', // Set the subject token type.
436430
aws_security_credentials_supplier: new AwsSupplier("AWS_REGION") // Set the custom supplier.
431+
service_account_impersonation_url: 'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/$EMAIL:generateAccessToken', // Set the service account impersonation url.
437432
}
438433
439434
// Create a new Auth client and use it to create service client, i.e. storage.
@@ -996,19 +991,19 @@ body: |-
996991
}
997992
998993
const clientOptions = {
999-
audience: '//iam.googleapis.com/locations/global/workforcePools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID', // Set the GCP audience.
994+
audience: '//iam.googleapis.com/locations/global/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID', // Set the GCP audience.
1000995
subject_token_type: 'urn:ietf:params:oauth:token-type:id_token', // Set the subject token type.
1001996
subject_token_supplier: new CustomSupplier() // Set the custom supplier.
1002997
}
1003998
1004999
const client = new CustomSupplier(clientOptions);
10051000
```
10061001
1007-
Where the audience is: `//iam.googleapis.com/locations/global/workforcePools/$WORKLOAD_POOL_ID/providers/$PROVIDER_ID`
1002+
Where the audience is: `//iam.googleapis.com/locations/global/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID`
10081003
10091004
Where the following variables need to be substituted:
10101005
1011-
* `WORKFORCE_POOL_ID`: The worforce pool ID.
1006+
* `$WORKFORCE_POOL_ID`: The worforce pool ID.
10121007
* `$PROVIDER_ID`: The provider ID.
10131008
10141009
and the workforce pool user project is the project number associated with the [workforce pools user project](https://cloud.google.com/iam/docs/workforce-identity-federation#workforce-pools-user-project).
@@ -1190,7 +1185,7 @@ body: |-
11901185
11911186
// Get impersonated credentials:
11921187
const authHeaders = await targetClient.getRequestHeaders();
1193-
// Do something with `authHeaders.Authorization`.
1188+
// Do something with `authHeaders.get('authorization')`.
11941189
11951190
// Use impersonated credentials:
11961191
const url = 'https://www.googleapis.com/storage/v1/b?project=anotherProjectID'
@@ -1265,7 +1260,7 @@ body: |-
12651260
const client = await googleAuth.getClient();
12661261
12671262
// Use the client to create a DownscopedClient.
1268-
const cabClient = new DownscopedClient(client, cab);
1263+
const cabClient = new DownscopedClient({authClient: client, credentialAccessBoundary: cab});
12691264
12701265
// Refresh the tokens.
12711266
const refreshedAccessToken = await cabClient.getAccessToken();

0 commit comments

Comments
 (0)