Skip to content

Clients don't use credentials returned from custom credentials providers when configured through extensions #6954

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

Closed
3 of 4 tasks
arnellebalane opened this issue Mar 20, 2025 · 2 comments
Assignees
Labels
bug This issue is a bug. closed-for-staleness p0 This issue is the highest priority

Comments

@arnellebalane
Copy link

arnellebalane commented Mar 20, 2025

Checkboxes for prior research

Describe the bug

When using an SDK extension to configure a credentials provider for a client, the client calls the credentials provider but does not use the credentials that it returns. Instead it uses the default credentials from the environment where it's running from.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.20.5

Reproduction Steps

First, you'll need to have default credentials for an account configured in your environment, let's call this AccountOne.
You'll also need temporary credentials from another account that we'll call AccountTwo.

import { STS } from '@aws-sdk/client-sts';
import { AwsCredentialIdentityProvider } from '@smithy/types';

const fromStaticCredentialProvider = async () => ({
    // TODO: Use temporary credentials from AccountTwo
    accessKeyId: 'accessKeyId',
    secretAccessKey: 'secretAccessKey',
    sessionToken: 'sessionToken',
});

interface ExtensionConfiguration {
    setCredentials(credentials: AwsCredentialIdentityProvider): void;
}

class StaticCredentialsExtension {
    static create(): StaticCredentialsExtension {
        return new StaticCredentialsExtension();
    }

    configure(extensionConfiguration: ExtensionConfiguration): void {
        extensionConfiguration.setCredentials(fromStaticCredentialProvider);
    }
}

// Returns AccountTwo identity which is expected
new STS({
    credentials: fromStaticCredentialProvider,
})
    .getCallerIdentity()
    .then((callerIdentity) => console.log('credentials', callerIdentity));

// Returns AccountOne identity which is incorrect
new STS({
    extensions: [StaticCredentialsExtension.create()],
})
    .getCallerIdentity()
    .then((callerIdentity) => console.log('extensions', callerIdentity));

Observed Behavior

When a client is configured with a credentials provider through the credentials parameter, it uses the credentials returned by that credentials provider when making API calls.

However if the credential provider is configured through an SDK extension in the extensions parameter, the client still calls the credentials provider function but does not use the credentials it returns when making API calls.

Expected Behavior

Configuring credentials through extensions should behave the same way as credentials parameter and should use the credentials returned from the credentials provider function.

Possible Solution

No response

Additional Information/Context

No response

@arnellebalane arnellebalane added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2025
@trivikr trivikr added p0 This issue is the highest priority and removed needs-triage This issue or PR still needs to be triaged. labels Mar 20, 2025
@kuhe kuhe assigned kuhe and trivikr Mar 21, 2025
@kuhe kuhe added pending-release This issue will be fixed by an approved PR that hasn't been released yet. and removed pending-release This issue will be fixed by an approved PR that hasn't been released yet. labels Mar 21, 2025
@kuhe
Copy link
Contributor

kuhe commented Mar 26, 2025

@kuhe kuhe added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Mar 26, 2025
@github-actions github-actions bot added closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Mar 31, 2025
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. closed-for-staleness p0 This issue is the highest priority
Projects
None yet
Development

No branches or pull requests

3 participants