Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add credential scope field #1122

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/happy-adults-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@smithy/middleware-endpoint": minor
"@smithy/types": minor
---

support credential scope
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ describe(createConfigValueProvider.name, () => {
expect(await createConfigValueProvider("x", "a", config)()).toEqual(1);
});

it("uses a special lookup for CredentialScope", async () => {
const config = {
credentials: async () => {
return {
credentialScope: "cred-scope",
};
},
};
expect(await createConfigValueProvider("credentialScope", "CredentialScope", config)()).toEqual("cred-scope");
});

it("should normalize endpoint objects into URLs", async () => {
const sampleUrl = "https://aws.amazon.com/";
const config = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export const createConfigValueProvider = <Config extends Record<string, unknown>
}
return configValue;
};
if (configKey === "credentialScope" || canonicalEndpointParamKey === "CredentialScope") {
return async () => {
const credentials = typeof config.credentials === "function" ? await config.credentials() : config.credentials;
syall marked this conversation as resolved.
Show resolved Hide resolved
const configValue: string = credentials?.credentialScope ?? credentials?.CredentialScope;
return configValue;
};
}
if (configKey === "endpoint" || canonicalEndpointParamKey === "endpoint") {
return async () => {
const endpoint = await configProvider();
Expand Down
5 changes: 5 additions & 0 deletions packages/types/src/identity/awsCredentialIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export interface AwsCredentialIdentity extends Identity {
* present for temporary credentials.
*/
readonly sessionToken?: string;

/**
* AWS credential scope for this set of credentials.
*/
readonly credentialScope?: string;
}

/**
Expand Down
Loading