question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prompt for MFA token for users

See original GitHub issue

When a profile is configured with mfa_serial for a role (Assume Role Provider), boto3 will request MFA tokens and assume the role. Why doesn’t a similar functionality exist for users? If a user profile has a mfa_serial parameter, shouldn’t boto3 ask for MFA tokens and authenticate with these?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
x4v13r64commented, Jul 10, 2019

I understand that I can script this process, I guess my question is why boto3 doesn’t do this automatically?

0reactions
notjamescommented, Jun 19, 2021

I’m in the process of trying to script around this exact problem myself so the answer to this question is relevant for my use-case as I’m finding myself trying to determine how to perform the following workflow:

context:

  • we have several accounts
    • one’s $HOME/.aws/credentials usually contains a few accounts IE:
[default]
aws_access_key_id...
aws_secret_access_key...

[org1-admin]
aws_access_key_id...
aws_secret_access_key...
mfa_serial...

[org2-admin]
aws_access_key_id...
aws_secret_access_key...

[org3-admin]
aws_access_key_id...
aws_secret_access_key...
...
  • one of these accounts (org1-admin as noted by the presence of mfa_serial) uses sub-accounts so there’s a config
    • The contents of the $HOME/.aws/config defines profiles under one of the aforementioned specified accounts:
[profile gen3-prod]
role_arn = ...
source_profile = org3-admin

[profile gen3-preprod]
role_arn = ...
source_profile = org3-admin

[profile gen3-dev]
role_arn = ...
source_profile = org3-admin

So the problem:

We have an inventory CLI tool which needs to do resource querying. The problem is that MFA was recently set to forced for only one of the main accounts org1-admin. The CLI tool needs to be able to ask the CLI admin for their MFA token if the CLI tool is querying against org1-admin resources and then assume an sts role just for that account. That’s fine. The problem is that there is no reason for the script to attempt to query for MFA until it’s necessary (when it needs to seek resources from org1-admin).

Since boto doesn’t seem to be intelligent enough to notice when an account requires MFA for authorization, I need to code this in. My main problem is that I’m not really sure how to introspect the boto3 object to see if mfa_serial exists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure AD Multi-Factor Authentication prompts and session ...
In this scenario, MFA prompts multiple times as each application requests an OAuth Refresh Token to be validated with MFA. In Azure AD,...
Read more >
Sure, keep me signed in! And don't prompt for MFA!
Today a short blog about MFA prompts, session lifetime, and cookies. This will give you an idea of how you can tune the...
Read more >
Users Aren't Getting MFA Prompts Every Day - Sean McAvinue
There is little value in prompting users every day to answer MFA on the ... we log on to Windows and receive a...
Read more >
Authenticate access using MFA through the AWS CLI
How do I use an MFA token to authenticate access to my AWS resources with the AWS Command Line Interface (AWS CLI)? ...
Read more >
Add Step-up Authentication - Auth0
Once the user successfully authenticates with MFA, Auth0 generates and sends a new access token that includes the high-value scope.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found