/// <summary>
        /// Uses the properties of the RespondToSmsMfaRequest object to respond to the current MFA
        /// authentication challenge using an asynchronous call
        /// </summary>
        /// <param name="smsMfaRequest">RespondToSmsMfaRequest object containing the necessary parameters to
        /// respond to the current SMS MFA authentication challenge</param>
        /// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
        /// if one exists</returns>
        public async Task <AuthFlowResponse> RespondToSmsMfaAuthAsync(RespondToSmsMfaRequest smsMfaRequest)
        {
            RespondToAuthChallengeRequest challengeRequest = new RespondToAuthChallengeRequest
            {
                ChallengeResponses = new Dictionary <string, string>
                {
                    { CognitoConstants.ChlgParamSmsMfaCode, smsMfaRequest.MfaCode },
                    { CognitoConstants.ChlgParamUsername, Username }
                },
                Session       = smsMfaRequest.SessionID,
                ClientId      = ClientID,
                ChallengeName = ChallengeNameType.SMS_MFA
            };

            if (!string.IsNullOrEmpty(SecretHash))
            {
                challengeRequest.ChallengeResponses.Add(CognitoConstants.ChlgParamSecretHash, SecretHash);
            }

            RespondToAuthChallengeResponse challengeResponse =
                await Provider.RespondToAuthChallengeAsync(challengeRequest).ConfigureAwait(false);

            UpdateSessionIfAuthenticationComplete(challengeResponse.ChallengeName, challengeResponse.AuthenticationResult);

            return(new AuthFlowResponse(challengeResponse.Session,
                                        challengeResponse.AuthenticationResult,
                                        challengeResponse.ChallengeName,
                                        challengeResponse.ChallengeParameters,
                                        new Dictionary <string, string>(challengeResponse.ResponseMetadata.Metadata)));
        }
示例#2
0
        /// <summary>
        /// Uses the properties of the RespondToSmsMfaRequest object to respond to the current MFA
        /// authentication challenge using an asynchronous call
        /// </summary>
        /// <param name="smsMfaRequest">RespondToSmsMfaRequest object containing the necessary parameters to
        /// respond to the current SMS MFA authentication challenge</param>
        /// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
        /// if one exists</returns>
        public void RespondToSmsMfaAuthAsync(RespondToSmsMfaRequest smsMfaRequest, AsyncCallback <AuthFlowResponse> callback = null)
        {
            RespondToAuthChallengeRequest challengeRequest = new RespondToAuthChallengeRequest
            {
                ChallengeResponses = new Dictionary <string, string>
                {
                    { CognitoConstants.ChlgParamSmsMfaCode, smsMfaRequest.MfaCode },
                    { CognitoConstants.ChlgParamUsername, Username }
                },
                Session       = smsMfaRequest.SessionID,
                ClientId      = ClientID,
                ChallengeName = ChallengeNameType.SMS_MFA
            };

            if (!string.IsNullOrEmpty(SecretHash))
            {
                challengeRequest.ChallengeResponses.Add(CognitoConstants.ChlgParamSecretHash, SecretHash);
            }

            Provider.RespondToAuthChallengeAsync(challengeRequest, r =>
            {
                if (r.Exception != null)
                {
                    callback?.Invoke(new AsyncResult <AuthFlowResponse>(null, r.Exception));
                    return;
                }

                RespondToAuthChallengeResponse challengeResponse = r.Response;
                UpdateSessionIfAuthenticationComplete(challengeResponse.ChallengeName, challengeResponse.AuthenticationResult);

                callback?.Invoke(new AsyncResult <AuthFlowResponse>(new AuthFlowResponse()
                {
                    SessionID            = challengeResponse.Session,
                    ChallengeName        = challengeResponse.ChallengeName,
                    AuthenticationResult = challengeResponse.AuthenticationResult,
                    ChallengeParameters  = challengeResponse.ChallengeParameters,
                    ClientMetadata       = new Dictionary <string, string>(challengeResponse.ResponseMetadata.Metadata)
                }, null));
            });
        }
示例#3
0
 /// <summary>
 /// Uses the properties of the RespondToSmsMfaRequest object to respond to the current MFA
 /// authentication challenge using an asynchronous call
 /// </summary>
 /// <param name="smsMfaRequest">RespondToSmsMfaRequest object containing the necessary parameters to
 /// respond to the current SMS MFA authentication challenge</param>
 /// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge,
 /// if one exists</returns>
 public virtual async Task <AuthFlowResponse> RespondToSmsMfaAuthAsync(RespondToSmsMfaRequest smsMfaRequest)
 {
     return(await RespondToMfaAuthAsync(smsMfaRequest).ConfigureAwait(false));
 }