Skip to content

Commit 04f73d0

Browse files
committed
fix(core/httpAuthSchemes): allow extensions to set signer credentials
1 parent e4d791d commit 04f73d0

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

packages/core/src/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export const resolveAwsSdkSigV4Config = <T>(
172172

173173
const params: SignatureV4Init & SignatureV4CryptoInit = {
174174
...config,
175-
credentials: boundCredentialsProvider,
175+
credentials: config.credentials as typeof boundCredentialsProvider,
176176
region: config.signingRegion,
177177
service: config.signingName,
178178
sha256,
@@ -208,7 +208,7 @@ export const resolveAwsSdkSigV4Config = <T>(
208208

209209
const params: SignatureV4Init & SignatureV4CryptoInit = {
210210
...config,
211-
credentials: boundCredentialsProvider,
211+
credentials: config.credentials as typeof boundCredentialsProvider,
212212
region: config.signingRegion,
213213
service: config.signingName,
214214
sha256,

packages/credential-provider-node/src/credential-provider-node.integ.spec.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { STS } from "@aws-sdk/client-sts";
1+
import { STS, STSExtensionConfiguration } from "@aws-sdk/client-sts";
22
import * as credentialProviderHttp from "@aws-sdk/credential-provider-http";
33
import { fromCognitoIdentity, fromCognitoIdentityPool, fromIni, fromWebToken } from "@aws-sdk/credential-providers";
44
import { HttpResponse } from "@smithy/protocol-http";
@@ -1267,6 +1267,34 @@ describe("credential-provider-node integration test", () => {
12671267
});
12681268
});
12691269

1270+
describe("extension provided credentials", () => {
1271+
it("allows an extension to modify client config credentials", async () => {
1272+
class OverrideCredentialsExtension {
1273+
static create(): OverrideCredentialsExtension {
1274+
return new OverrideCredentialsExtension();
1275+
}
1276+
1277+
configure(extensionConfiguration: STSExtensionConfiguration): void {
1278+
extensionConfiguration.setCredentials(async () => ({
1279+
accessKeyId: "STS_AK",
1280+
secretAccessKey: "STS_SAK",
1281+
}));
1282+
}
1283+
}
1284+
1285+
const client = new STS({
1286+
extensions: [OverrideCredentialsExtension.create()],
1287+
});
1288+
1289+
const credentials = await client.config.credentials({});
1290+
1291+
expect(credentials).toEqual({
1292+
accessKeyId: "STS_AK",
1293+
secretAccessKey: "STS_SAK",
1294+
});
1295+
});
1296+
});
1297+
12701298
describe("No credentials available", () => {
12711299
it("should throw CredentialsProviderError", async () => {
12721300
process.env.AWS_EC2_METADATA_DISABLED = "true";

0 commit comments

Comments
 (0)