/*
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System.Collections.Generic;
using Amazon.CognitoIdentityProvider;
using Amazon.CognitoIdentityProvider.Model;
namespace Amazon.Extensions.CognitoAuthentication
{
///
/// Class necessary for allowing users to respond to authentication results
/// at each step of the authentication flow
///
public class AuthFlowResponse
{
///
/// Constructs an AuthFlowResponse object
///
/// The authentication workflow session id.
/// The result of the Authentication workflow
/// The challenge name if any.
/// The challenge parameters if any.
/// The client metadata.
public AuthFlowResponse(string sessionId, AuthenticationResultType authenticationResult, ChallengeNameType challengeName, IDictionary challengeParameters, IDictionary clientMetadata)
{
SessionID = sessionId;
ChallengeName = challengeName;
AuthenticationResult = authenticationResult;
ChallengeParameters = challengeParameters;
ClientMetadata = clientMetadata;
}
///
/// The sessionID for the current authentication flow.
///
public string SessionID { get; }
///
/// The current challenge name for the authentication flow.
///
public ChallengeNameType ChallengeName { get; }
///
/// The current authentication result for the authentication flow.
///
public AuthenticationResultType AuthenticationResult { get; }
///
/// The challenge parameters for the current authentication flow.
///
public IDictionary ChallengeParameters { get; }
///
/// The client metadata for the current authentication flow. Only
/// applicable for custom authentication.
///
public IDictionary ClientMetadata { get; }
}
///
/// Class containing the necessary properities to initiate SRP authentication flow
///
public class InitiateSrpAuthRequest
{
///
/// The password for the corresponding CognitoUser.
///
public string Password { get; set; }
///
/// The password for the device associated with the corresponding CognitoUser
///
public string DevicePass { get; set; }
///
/// The device password verifier for the device associated with the corresponding CognitoUser
///
public string DeviceVerifier { get; set; }
///
/// The Device Key Group for the device associated with the corresponding CognitoUser
///
public string DeviceGroupKey { get; set; }
///
/// The client metadata for the current authentication flow.
///
public IDictionary ClientMetadata { get; set; }
///
/// Enable custom auth flow
/// https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-authentication-flow.html#Using-SRP-password-verification-in-custom-authentication-flow
///
public bool IsCustomAuthFlow { get; set; }
}
///
/// Class containing the necessary properities to initiate custom authentication flow
///
public class InitiateCustomAuthRequest
{
///
/// The authentication parameters for the current authentication flow.
///
public IDictionary AuthParameters { get; set; }
///
/// The client metadata for the current authentication flow.
///
public IDictionary ClientMetadata { get; set; }
}
///
/// Class containing the necessary properities to initiate either REFRESH_TOKEN or
/// REFRESH_TOKEN_AUTH authentication
///
public class InitiateRefreshTokenAuthRequest
{
///
/// The authentication flow type for the current authentication flow;
/// either REFRESH_TOKEN or REFRESH_TOKEN_AUTH
///
public AuthFlowType AuthFlowType { get; set; }
}
///
/// Class containing the necessary properities to respond to an MFA authentication challenge
///
public class RespondToMfaRequest
{
///
/// The session ID for the current authentication flow.
///
public virtual string SessionID { get; set; }
///
/// The MFA verification code needed to authenticate the user.
///
public virtual string MfaCode { get; set; }
///
/// The challenge name type for the current authentication flow.
///
public virtual ChallengeNameType ChallengeNameType { get; set; }
}
///
/// Class containing the necessary properities to respond to an MFA authentication challenge
///
public class RespondToSmsMfaRequest : RespondToMfaRequest
{
///
/// The challenge name type for the current authentication flow.
///
public override ChallengeNameType ChallengeNameType { get { return ChallengeNameType.SMS_MFA; } set { } }
}
///
/// Class containing the necessary properities to respond to a new password required authentication challenge
///
public class RespondToNewPasswordRequiredRequest
{
///
/// The session ID for the current authentication flow.
///
public string SessionID { get; set; }
///
/// The new desired password for the user.
///
public string NewPassword { get; set; }
}
///
/// Class containing the necessary properities to respond to a custom authentication challenge
///
public class RespondToCustomChallengeRequest
{
///
/// The authentication parameters for the current authentication flow.
///
public IDictionary ChallengeParameters { get; set; }
///
/// The client metadata for any custom workflows that this action triggers
///
public IDictionary ClientMetadata { get; set; } = new Dictionary();
///
/// The sessionID for the current authentication flow.
///
public string SessionID { get; set; }
}
///
/// Class containing the necessary parameters to inititate ADMIN_NO_SRP authentication
///
public class InitiateAdminNoSrpAuthRequest
{
///
/// The associated user's password
///
public string Password { get; set; }
///
/// Optional client metadata to provide in the Initiate Admin Authentication API call
///
public IDictionary ClientMetadata { get; set; }
}
}