Skip to content

Commit

Permalink
fix: ensures GCE metadata sets email field for ID tokens (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored and bcoe committed Jan 16, 2020
1 parent 2053228 commit e45b73d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/auth/computeclient.ts
Expand Up @@ -109,7 +109,7 @@ export class Compute extends OAuth2Client {
async fetchIdToken(targetAudience: string): Promise<string> {
const idTokenPath =
`service-accounts/${this.serviceAccountEmail}/identity` +
`?audience=${targetAudience}`;
`?format=full&audience=${targetAudience}`;
let idToken: string;
try {
const instanceOptions: gcpMetadata.Options = {
Expand Down
4 changes: 2 additions & 2 deletions test/test.compute.ts
Expand Up @@ -235,7 +235,7 @@ it('should accept a custom service account', async () => {

it('should request the identity endpoint for fetchIdToken', async () => {
const targetAudience = 'a-target-audience';
const path = `${identityPath}?audience=${targetAudience}`;
const path = `${identityPath}?format=full&audience=${targetAudience}`;

const tokenFetchNock = nock(HOST_ADDRESS)
.get(path, undefined, {reqheaders: HEADERS})
Expand All @@ -251,7 +251,7 @@ it('should request the identity endpoint for fetchIdToken', async () => {

it('should throw an error if metadata server is unavailable', async () => {
const targetAudience = 'a-target-audience';
const path = `${identityPath}?audience=${targetAudience}`;
const path = `${identityPath}?format=full&audience=${targetAudience}`;

const tokenFetchNock = nock(HOST_ADDRESS)
.get(path, undefined, {reqheaders: HEADERS})
Expand Down

0 comments on commit e45b73d

Please sign in to comment.