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

Any way to directly access the ad-hoc IAM access key ID & secret key? #337

Closed
ffxsam opened this issue Feb 22, 2018 · 4 comments
Closed
Labels
Auth Related to Auth components/category

Comments

@ffxsam
Copy link
Contributor

ffxsam commented Feb 22, 2018

If I understand Cognito correctly, it basically creates an ad-hoc IAM user every time someone authenticates, and uses that IAM user to access AWS services.. is that right?

Is there any way to access these strings directly? I have a special case where I don't think the AWS JS SDK is going to work for me, and I need to call the S3 REST API directly, in which case I'll have to formulate an AWS authorization header.

@mlabieniec
Copy link
Contributor

mlabieniec commented Feb 22, 2018

@ffxsam no, cognito does not create IAM users. Cognito is essentially 2 services: User Pools and Federated Identity. The users are part of user pools and are it's own service. The permissions for that user are governed by the IAM role associated with them or their group:
https://docs.aws.amazon.com/cognito/latest/developerguide/iam-roles.html

For the SDK directly, you can call it by just passing credentials:
See #335

For API, you can essentially call any AWS API via the API category and it will take care of signing the URL for you:
https://aws.github.io/aws-amplify/media/api_guide.html#manual-setup

To access the IAM creds you can:

Auth.currentCredentials()
  .then(credentials => {
    // access keys available on:
    let creds = Auth.essentialCredentials(credentials)
  })

@ffxsam
Copy link
Contributor Author

ffxsam commented Feb 22, 2018

BTW, this is related to #334 - as I may have to use S3 REST API directly to get fine-grained upload progress.

@mlabieniec mlabieniec added enhancement Auth Related to Auth components/category labels Feb 22, 2018
@ffxsam
Copy link
Contributor Author

ffxsam commented Feb 23, 2018

Ah.. I just tried Auth.currentCredentials(). I might've mis-worded it when I said it creates an ad-hoc IAM user, but you do indeed get a dynamically generated IAM key. I see an accessKeyId and secretAccessKey in the result of that function call.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Auth Related to Auth components/category
Projects
None yet
Development

No branches or pull requests

2 participants