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(sso_credentials): if new sso session format in config, use sso token provider in sso credentials #4267

Merged
merged 3 commits into from
Nov 11, 2022

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Nov 9, 2022

  • in SSO Credentials, use the SSO Token Provider to get the token string if the config format is in the new format with an sso-session name.
Checklist
  • npm run test passes
  • n/a .d.ts file is updated
  • changelog is added, npm run add-change
  • run bundle exec rake docs:api and inspect doc/latest/index.html if documentation is changed
  • n/a run npm run integration if integration test is changed
  • n/a non-code related change (markdown/git settings etc)

testing:

sso.js

var AWS = require('../../lib/aws');
var S3 = require('../../clients/s3');

Promise.resolve()
  .then(function () {
    return new Promise(function (resolve) {
      var creds = new AWS.SsoCredentials({
        callback: function (err, done) {
          resolve(err || creds);
        }
      });
    });
  })
  .then(function (credentials) {
    console.log('credentials from:', credentials.profile);
    return new S3({credentials: credentials, region: 'us-east-1'}).listBuckets({}).promise();
  })
  .then(function (data) {
    console.log('list buckets OK');
  })
  .catch(function (err) {
    console.error('oh no', err);
  });
test:
	make legacy
	make new

legacy:
	AWS_SDK_LOAD_CONFIG=1 AWS_PROFILE=sso-legacy node sso

new:
	AWS_SDK_LOAD_CONFIG=1 AWS_PROFILE=sso-token node sso

~/.aws/config

[profile sso-legacy]
sso_account_id = ****
sso_region = us-east-1
sso_role_name = ******
sso_start_url = https://d-******.awsapps.com/start

[profile sso-token]
sso_session = dev
sso_account_id = ****
sso_role_name = ******

[sso-session dev]
sso_region = us-east-1
sso_start_url = https://d-******.awsapps.com/start
sso_registration_scopes = sso:account:access

@kuhe
Copy link
Contributor Author

kuhe commented Nov 9, 2022

corresponding v3 PR: aws/aws-sdk-js-v3#4145

@kuhe kuhe merged commit 5542025 into aws:master Nov 11, 2022
@kuhe kuhe deleted the feat/sso branch November 11, 2022 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants