Skip to content

Commit

Permalink
Added support for analytics metadata for collecting Amazon Pinpoint m…
Browse files Browse the repository at this point in the history
…etrics.
  • Loading branch information
ashishdhingra committed Jul 9, 2024
1 parent 1b8b746 commit ede8b26
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<DelaySign>false</DelaySign>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.5.4</Version>
<Version>2.5.5</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public AuthFlowResponse(string sessionId, AuthenticationResultType authenticatio
/// applicable for custom authentication.
/// </summary>
public IDictionary<string, string> ClientMetadata { get; }

/// <summary>
/// The analytics metadata for collecting Amazon Pinpoint metrics.
/// </summary>
public AnalyticsMetadataType AnalyticsMetadata { get; set; }
}

/// <summary>
Expand All @@ -94,7 +99,11 @@ public class InitiateSrpAuthRequest
/// <summary>
/// The client metadata for the current authentication flow.
/// </summary>
public IDictionary<string, string> ClientMetadata { get; set; }
public IDictionary<string, string> ClientMetadata { get; set; }
/// <summary>
/// The analytics metadata for collecting Amazon Pinpoint metrics.
/// </summary>
public AnalyticsMetadataType AnalyticsMetadata { get; set; }
/// <summary>
/// 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
Expand All @@ -115,7 +124,12 @@ public class InitiateCustomAuthRequest
/// <summary>
/// The client metadata for the current authentication flow.
/// </summary>
public IDictionary<string, string> ClientMetadata { get; set; }
public IDictionary<string, string> ClientMetadata { get; set; }

/// <summary>
/// The analytics metadata for collecting Amazon Pinpoint metrics.
/// </summary>
public AnalyticsMetadataType AnalyticsMetadata { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -194,6 +208,11 @@ public class RespondToCustomChallengeRequest
/// </summary>
public IDictionary<string, string> ClientMetadata { get; set; } = new Dictionary<string, string>();

/// <summary>
/// The analytics metadata for collecting Amazon Pinpoint metrics.
/// </summary>
public AnalyticsMetadataType AnalyticsMetadata { get; set; }

/// <summary>
/// The sessionID for the current authentication flow.
/// </summary>
Expand All @@ -213,6 +232,11 @@ public class InitiateAdminNoSrpAuthRequest
/// <summary>
/// Optional client metadata to provide in the Initiate Admin Authentication API call
/// </summary>
public IDictionary<string, string> ClientMetadata { get; set; }
public IDictionary<string, string> ClientMetadata { get; set; }

/// <summary>
/// Optional analytics metadata for collecting Amazon Pinpoint metrics.
/// </summary>
public AnalyticsMetadataType AnalyticsMetadata { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public virtual async Task<AuthFlowResponse> StartWithSrpAuthAsync(InitiateSrpAut
initiateRequest.ClientMetadata = new Dictionary<string, string>(srpRequest.ClientMetadata);
}

initiateRequest.AnalyticsMetadata = srpRequest.AnalyticsMetadata;

if (srpRequest.IsCustomAuthFlow)
{
initiateRequest.AuthFlow = AuthFlowType.CUSTOM_AUTH;
Expand All @@ -84,6 +86,8 @@ public virtual async Task<AuthFlowResponse> StartWithSrpAuthAsync(InitiateSrpAut
challengeRequest.ClientMetadata = new Dictionary<string, string>(srpRequest.ClientMetadata);
}

challengeRequest.AnalyticsMetadata = srpRequest.AnalyticsMetadata;

bool challengeResponsesValid = challengeRequest != null && challengeRequest.ChallengeResponses != null;
bool deviceKeyValid = Device != null && !string.IsNullOrEmpty(Device.DeviceKey);

Expand Down Expand Up @@ -238,7 +242,8 @@ public virtual async Task<AuthFlowResponse> StartWithCustomAuthAsync(InitiateCus
AuthFlow = AuthFlowType.CUSTOM_AUTH,
AuthParameters = new Dictionary<string, string>(customRequest.AuthParameters),
ClientId = ClientID,
ClientMetadata = new Dictionary<string, string>(customRequest.ClientMetadata)
ClientMetadata = new Dictionary<string, string>(customRequest.ClientMetadata),
AnalyticsMetadata = customRequest.AnalyticsMetadata
};

InitiateAuthResponse initiateResponse = await Provider.InitiateAuthAsync(authRequest, cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -283,6 +288,7 @@ public virtual async Task<AuthFlowResponse> RespondToCustomAuthAsync(RespondToCu
ClientId = ClientID,
ChallengeResponses = new Dictionary<string, string>(customRequest.ChallengeParameters),
ClientMetadata = new Dictionary<string, string>(customRequest.ClientMetadata),
AnalyticsMetadata = customRequest.AnalyticsMetadata,
Session = customRequest.SessionID
};

Expand Down Expand Up @@ -730,7 +736,7 @@ private AdminInitiateAuthRequest CreateAdminAuthRequest(InitiateAdminNoSrpAuthRe
AuthParameters = new Dictionary<string, string>()
{
{ CognitoConstants.ChlgParamUsername, Username },
{CognitoConstants.ChlgParamPassword, adminRequest.Password }
{ CognitoConstants.ChlgParamPassword, adminRequest.Password }
}
};

Expand All @@ -749,6 +755,8 @@ private AdminInitiateAuthRequest CreateAdminAuthRequest(InitiateAdminNoSrpAuthRe
returnRequest.ClientMetadata = new Dictionary<string, string>(adminRequest.ClientMetadata);
}

returnRequest.AnalyticsMetadata = adminRequest.AnalyticsMetadata;

return returnRequest;
}

Expand Down

0 comments on commit ede8b26

Please sign in to comment.