Skip to content

Commit 3d955db

Browse files
committed
[CognitoUserPools] Fix parameter order; add password to custom auth flow to handle password verifier
1 parent 8836b56 commit 3d955db

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

aws-android-sdk-cognitoidentityprovider/src/main/java/com/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,10 +2264,8 @@ public Runnable respondToChallenge(final RespondToAuthChallengeRequest challenge
22642264
final AuthenticationHandler callback, final boolean runInBackground) {
22652265
try {
22662266
if (challengeResponse != null && challengeResponse.getChallengeResponses() != null) {
2267-
final Map<String, String> challengeResponses = challengeResponse
2268-
.getChallengeResponses();
2269-
challengeResponses.put(CognitoServiceConstants.CHLG_RESP_DEVICE_KEY, deviceKey);
2270-
challengeResponse.setChallengeResponses(challengeResponses);
2267+
challengeResponse.getChallengeResponses()
2268+
.put(CognitoServiceConstants.CHLG_RESP_DEVICE_KEY, deviceKey);
22712269
}
22722270
final RespondToAuthChallengeResult challenge = cognitoIdentityProviderClient
22732271
.respondToAuthChallenge(challengeResponse);
@@ -2331,9 +2329,9 @@ private Runnable startWithUserSrpAuth(final AuthenticationDetails authentication
23312329
if (authenticationDetails.getPassword() != null) {
23322330
final RespondToAuthChallengeRequest challengeRequest = userSrpAuthRequest(
23332331
initiateAuthResult.getChallengeParameters(),
2332+
authenticationDetails.getPassword(),
23342333
initiateAuthResult.getChallengeName(),
23352334
initiateAuthResult.getSession(),
2336-
authenticationDetails.getPassword(),
23372335
authenticationHelper
23382336
);
23392337
return respondToChallenge(challengeRequest, callback, runInBackground);
@@ -2479,19 +2477,21 @@ public void run() {
24792477
}
24802478
}
24812479
} else if (CognitoServiceConstants.CHLG_TYPE_USER_PASSWORD_VERIFIER.equals(challengeName)) {
2482-
return new Runnable() {
2480+
if (authenticationDetails == null || authenticationDetails.getPassword() == null) {
2481+
return nextTask;
2482+
}
2483+
2484+
nextTask = new Runnable() {
24832485
@Override
24842486
public void run() {
2485-
final AuthenticationHelper authenticationHelper = new AuthenticationHelper(
2486-
pool.getUserPoolId());
2487-
final Map<String, String> challengeParameters = challenge.getChallengeParameters();
2488-
cognitoIdentityProviderClient.respondToAuthChallenge(userSrpAuthRequest(
2489-
challengeParameters,
2487+
final RespondToAuthChallengeRequest challengeRequest = userSrpAuthRequest(
2488+
challenge.getChallengeParameters(),
2489+
authenticationDetails.getPassword(),
24902490
challenge.getChallengeName(),
24912491
challenge.getSession(),
2492-
authenticationDetails.getPassword(),
2493-
authenticationHelper
2494-
));
2492+
new AuthenticationHelper(pool.getUserPoolId())
2493+
);
2494+
respondToChallenge(challengeRequest, callback, runInBackground);
24952495
}
24962496
};
24972497
} else if (CognitoServiceConstants.CHLG_TYPE_SMS_MFA.equals(challengeName)

aws-android-sdk-cognitoidentityprovider/src/main/java/com/amazonaws/mobileconnectors/cognitoidentityprovider/continuations/AuthenticationDetails.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ public void setAuthenticationType(String authenticationType) {
9191
}
9292
}
9393

94+
public void setPassword(final String password) {
95+
this.password = password;
96+
}
97+
9498
/**
9599
* This method returns the password.
96100
*

0 commit comments

Comments
 (0)