Skip to content

Commit

Permalink
fix(credential-providers): avoid sharing http2 requestHandler with in…
Browse files Browse the repository at this point in the history
…ner STS
  • Loading branch information
kuhe committed Aug 15, 2024
1 parent 84fd78b commit da4f61e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions clients/client-sts/src/defaultStsRoleAssumers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ export const getDefaultRoleAssumer = (
stsOptions?.parentClientConfig?.region,
credentialProviderLogger
);
const isCompatibleRequestHandler = !isH2(requestHandler);

stsClient = new stsClientCtor({
// A hack to make sts client uses the credential in current closure.
credentialDefaultProvider: () => async () => closureSourceCreds,
region: resolvedRegion,
requestHandler: requestHandler as any,
requestHandler: isCompatibleRequestHandler ? (requestHandler as any) : undefined,
logger: logger as any,
});
}
Expand Down Expand Up @@ -157,9 +159,11 @@ export const getDefaultRoleAssumerWithWebIdentity = (
stsOptions?.parentClientConfig?.region,
credentialProviderLogger
);
const isCompatibleRequestHandler = !isH2(requestHandler);

stsClient = new stsClientCtor({
region: resolvedRegion,
requestHandler: requestHandler as any,
requestHandler: isCompatibleRequestHandler ? (requestHandler as any) : undefined,
logger: logger as any,
});
}
Expand Down Expand Up @@ -206,3 +210,7 @@ export const decorateDefaultCredentialProvider =
),
...input,
});

const isH2 = (requestHandler: any): boolean => {
return requestHandler?.metadata?.handlerProtocol === "h2";
};
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ export const getDefaultRoleAssumer = (
stsOptions?.parentClientConfig?.region,
credentialProviderLogger
);
const isCompatibleRequestHandler = !isH2(requestHandler);

stsClient = new stsClientCtor({
// A hack to make sts client uses the credential in current closure.
credentialDefaultProvider: () => async () => closureSourceCreds,
region: resolvedRegion,
requestHandler: requestHandler as any,
requestHandler: isCompatibleRequestHandler ? (requestHandler as any) : undefined,
logger: logger as any,
});
}
Expand Down Expand Up @@ -154,9 +156,11 @@ export const getDefaultRoleAssumerWithWebIdentity = (
stsOptions?.parentClientConfig?.region,
credentialProviderLogger
);
const isCompatibleRequestHandler = !isH2(requestHandler);

stsClient = new stsClientCtor({
region: resolvedRegion,
requestHandler: requestHandler as any,
requestHandler: isCompatibleRequestHandler ? (requestHandler as any) : undefined,
logger: logger as any,
});
}
Expand Down Expand Up @@ -203,3 +207,7 @@ export const decorateDefaultCredentialProvider =
),
...input,
});

const isH2 = (requestHandler: any): boolean => {
return requestHandler?.metadata?.handlerProtocol === "h2";
};

0 comments on commit da4f61e

Please sign in to comment.