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

Missing updateInternalUsername call in initiateCustomAuthRequest #657

Closed
dbathily opened this issue Jan 16, 2019 · 4 comments
Closed

Missing updateInternalUsername call in initiateCustomAuthRequest #657

dbathily opened this issue Jan 16, 2019 · 4 comments
Assignees
Labels
bug Something isn't working closing soon Issue will auto-close if there is no additional activity within 7 days. cognito Issues with the AWS Android SDK for Cognito pending-community-response Issue is pending response from the issue requestor

Comments

@dbathily
Copy link

Describe the bug
When initiating a custom auth without clientSecret I have this error:

W/System.err: com.amazonaws.mobileconnectors.cognitoidentityprovider.exceptions.CognitoParameterInvalidException: user ID cannot be null
        at com.amazonaws.mobileconnectors.cognitoidentityprovider.util.CognitoSecretHash.getSecretHash(CognitoSecretHash.java:45)
W/System.err:     at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser.initiateCustomAuthRequest(CognitoUser.java:2760)
        at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser.startWithCustomAuth(CognitoUser.java:2383)
        at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser.initiateUserAuthentication(CognitoUser.java:775)
        at com.amazonaws.mobileconnectors.cognitoidentityprovider.continuations.AuthenticationContinuation$1.run(AuthenticationContinuation.java:100)
        at java.lang.Thread.run(Thread.java:764)

To Reproduce

val alias = "..."
userPoool.getUser(alias).getSessionInBackground(object: AuthenticationHandler {
            override fun onSuccess(userSession: CognitoUserSession?, newDevice: CognitoDevice?) {
            }

            override fun onFailure(exception: Exception?) {
                exception?.printStackTrace()
            }

            override fun getAuthenticationDetails(authenticationContinuation: AuthenticationContinuation?, userId: String?) {
                val details = AuthenticationDetails(userId, mapOf(
                        CognitoServiceConstants.AUTH_PARAM_USERNAME to userId
                ), null)
                authenticationContinuation?.setAuthenticationDetails(details)
                authenticationContinuation?.continueTask()
            }

            override fun authenticationChallenge(continuation: ChallengeContinuation?) {
                TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
            }

            override fun getMFACode(continuation: MultiFactorAuthenticationContinuation?) {
                TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
            }
        })

Which AWS service(s) are affected?

Cognito

Expected behavior

Should not raised and exception, internalUsername must be updated with the parameters

Environment(please complete the following information):

  • SDK Version: 2.9
@palpatim palpatim added the cognito Issues with the AWS Android SDK for Cognito label Jan 16, 2019
@palpatim palpatim assigned palpatim and minbi and unassigned palpatim Jan 16, 2019
@palpatim
Copy link
Member

Thanks for reporting the issue @dbathily. We will investigate and update this thread when we have more info or questions.

@anees17861
Copy link

anees17861 commented Jan 22, 2019

+1

We're facing a similar issue, using custom authentication flow on Android (Java)

From looking at your SDK,

startWithUserPasswordAuth definition:

private Runnable startWithUserPasswordAuth(final AuthenticationDetails authenticationDetails,
            final AuthenticationHandler callback, final boolean runInBackground) {
        try {
            final InitiateAuthRequest initiateAuthRequest = initiateUserPasswordAuthRequest(
                authenticationDetails);
            final InitiateAuthResult initiateAuthResult = cognitoIdentityProviderClient
                    .initiateAuth(initiateAuthRequest);
            **this.usernameInternal = initiateAuthResult.getChallengeParameters()
                    .get(CognitoServiceConstants.CHLG_PARAM_USER_ID_FOR_SRP);**
            return handleChallenge(initiateAuthResult, callback, runInBackground);
        } catch (final Exception e) {
            return new Runnable() {
                @Override
                public void run() {
                    callback.onFailure(e);
                }
            };
        }
}

userSrpAuthRequest

private RespondToAuthChallengeRequest userSrpAuthRequest(InitiateAuthResult challenge,
            AuthenticationDetails authenticationDetails,
            AuthenticationHelper authenticationHelper) {
        final String userIdForSRP = challenge.getChallengeParameters()
                .get(CognitoServiceConstants.CHLG_PARAM_USER_ID_FOR_SRP);
        **this.usernameInternal = challenge.getChallengeParameters()
                .get(CognitoServiceConstants.CHLG_PARAM_USERNAME);**
        this.deviceKey = CognitoDeviceHelper.getDeviceKey(usernameInternal, pool.getUserPoolId(),
                context);
        secretHash = CognitoSecretHash.getSecretHash(usernameInternal, clientId, clientSecret);

However, no such calls to set usernameInternal are being made in any of the customAuth related functions

@frankmuellr frankmuellr added the bug Something isn't working label Jan 22, 2019
@minbi
Copy link
Contributor

minbi commented Feb 4, 2019

Hi @dbathily @anees17861 ,

We have released a fix for this issue in version 2.11.1. Please see if this fixes the issue for you.

@minbi minbi added pending-community-response Issue is pending response from the issue requestor closing soon Issue will auto-close if there is no additional activity within 7 days. labels Feb 4, 2019
@stale
Copy link

stale bot commented Feb 15, 2019

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

@stale stale bot closed this as completed Feb 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working closing soon Issue will auto-close if there is no additional activity within 7 days. cognito Issues with the AWS Android SDK for Cognito pending-community-response Issue is pending response from the issue requestor
Projects
None yet
Development

No branches or pull requests

5 participants