Skip to content

Commit 86e4aa6

Browse files
committed
Fix audience and scopes when using WIF and non-default universes.
1 parent fc21748 commit 86e4aa6

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

dist/main/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/workload_identity_federation.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Google LLC
1+
// Copyright 2026 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -56,8 +56,12 @@ export class WorkloadIdentityFederationClient extends Client implements AuthClie
5656
this.#workloadIdentityProviderName = opts.workloadIdentityProviderName;
5757
this.#serviceAccount = opts.serviceAccount;
5858

59-
const iamHost = new URL(this._endpoints.iam).host;
60-
this.#audience = `//${iamHost}/${this.#workloadIdentityProviderName}`;
59+
if (opts.audience) {
60+
this.#audience = opts.audience;
61+
} else {
62+
const iamHost = new URL(this._endpoints.iam).host;
63+
this.#audience = `//${iamHost}/${this.#workloadIdentityProviderName}`;
64+
}
6165
this._logger.debug(`Computed audience`, this.#audience);
6266
}
6367

@@ -88,7 +92,7 @@ export class WorkloadIdentityFederationClient extends Client implements AuthClie
8892
audience: this.#audience,
8993
grantType: `urn:ietf:params:oauth:grant-type:token-exchange`,
9094
requestedTokenType: `urn:ietf:params:oauth:token-type:access_token`,
91-
scope: `${this._endpoints.www}/auth/cloud-platform`,
95+
scope: `https://www.googleapis.com/auth/cloud-platform`,
9296
subjectTokenType: `urn:ietf:params:oauth:token-type:jwt`,
9397
subjectToken: this.#githubOIDCToken,
9498
};

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export async function run(logger: Logger) {
128128
githubOIDCTokenAudience: oidcTokenAudience,
129129
workloadIdentityProviderName: workloadIdentityProvider,
130130
serviceAccount: serviceAccount,
131+
audience: getInput('audience'),
131132
});
132133
} else {
133134
logger.debug(`Using credentials JSON`);

0 commit comments

Comments
 (0)