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

Support SOFTWARE_TOKEN_MFA challenge in AWSSRP #169

Open
kornpow opened this issue Feb 18, 2022 · 0 comments
Open

Support SOFTWARE_TOKEN_MFA challenge in AWSSRP #169

kornpow opened this issue Feb 18, 2022 · 0 comments

Comments

@kornpow
Copy link

kornpow commented Feb 18, 2022

Found this library and it has been helpful. I noticed I had to do a little bit of custom code to get it working with SOFTWARE_TOKEN_MFA.

Here is the code I used to get it working:

from warrant.aws_srp import AWSSRP
import boto3

cognito = boto3.client('cognito-idp')

user_pool_id = "us-west-2_blah"
app_client_id = "app-client-id-1234"
username = "[email protected]


aws = AWSSRP(
    username=username,
    password={redacted}, 
    pool_id=user_pool_id,
    client_id=app_client_id,
    client=cognito
)

tokens = aws.authenticate_user()


response = cognito.respond_to_auth_challenge(
    ClientId=app_client_id,
    ChallengeName="SOFTWARE_TOKEN_MFA",
    Session=tokens["Session"],
    ChallengeResponses={"SOFTWARE_TOKEN_MFA_CODE":"{redacted}", "USERNAME": username}
)

I noticed this problem, since tokens = aws.authenticate_user() returned a dict with a Session key instead of what I was expecting.

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

No branches or pull requests

1 participant