Skip to content

Commit ffd1098

Browse files
committed
Implementing cognito trigger events
PreSignup PostConfirmation PreAuthentication PostAuthentication DefineAuthChallenge CreateAuthChallenge VerifyAuthChallenge PreTokenGeneration MigrateUser CustomMessage CustomEmailSender CustomSmsSender
1 parent 658f030 commit ffd1098

File tree

58 files changed

+2063
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2063
-5
lines changed

Libraries/src/Amazon.Lambda.CognitoEvents/Amazon.Lambda.CognitoEvents.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<PropertyGroup>
66
<Description>Amazon Lambda .NET Core support - CognitoEvents package.</Description>
7-
<TargetFramework>netstandard2.0</TargetFramework>
7+
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
88
<AssemblyTitle>Amazon.Lambda.CognitoEvents</AssemblyTitle>
99
<VersionPrefix>2.0.0</VersionPrefix>
1010
<AssemblyName>Amazon.Lambda.CognitoEvents</AssemblyName>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Amazon.Lambda.CognitoEvents
4+
{
5+
/// <summary>
6+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-define-auth-challenge.html
7+
/// </summary>
8+
[DataContract]
9+
public class ChallengeResultElement
10+
{
11+
/// <summary>
12+
/// The challenge type.One of: CUSTOM_CHALLENGE, SRP_A, PASSWORD_VERIFIER, SMS_MFA, DEVICE_SRP_AUTH, DEVICE_PASSWORD_VERIFIER, or ADMIN_NO_SRP_AUTH.
13+
/// </summary>
14+
[DataMember(Name = "challengeName")]
15+
#if NETCOREAPP3_1
16+
[System.Text.Json.Serialization.JsonPropertyName("challengeName")]
17+
# endif
18+
public string ChallengeName { get; set; }
19+
20+
/// <summary>
21+
/// Set to true if the user successfully completed the challenge, or false otherwise.
22+
/// </summary>
23+
[DataMember(Name = "challengeResult")]
24+
#if NETCOREAPP3_1
25+
[System.Text.Json.Serialization.JsonPropertyName("challengeResult")]
26+
# endif
27+
public bool ChallengeResult { get; set; }
28+
29+
/// <summary>
30+
/// Your name for the custom challenge.Used only if challengeName is CUSTOM_CHALLENGE.
31+
/// </summary>
32+
[DataMember(Name = "challengeMetadata")]
33+
#if NETCOREAPP3_1
34+
[System.Text.Json.Serialization.JsonPropertyName("challengeMetadata")]
35+
# endif
36+
public string ChallengeMetadata { get; set; }
37+
}
38+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Collections.Generic;
2+
using System.Runtime.Serialization;
3+
4+
namespace Amazon.Lambda.CognitoEvents
5+
{
6+
/// <summary>
7+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html
8+
/// </summary>
9+
[DataContract]
10+
public class ClaimOverrideDetails
11+
{
12+
/// <summary>
13+
/// A map of one or more key-value pairs of claims to add or override. For group related claims, use groupOverrideDetails instead.
14+
/// </summary>
15+
[DataMember(Name = "claimsToAddOrOverride")]
16+
#if NETCOREAPP3_1
17+
[System.Text.Json.Serialization.JsonPropertyName("claimsToAddOrOverride")]
18+
# endif
19+
public Dictionary<string, string> ClaimsToAddOrOverride { get; set; } = new Dictionary<string, string>();
20+
21+
/// <summary>
22+
/// A list that contains claims to be suppressed from the identity token.
23+
/// </summary>
24+
[DataMember(Name = "claimsToSuppress")]
25+
#if NETCOREAPP3_1
26+
[System.Text.Json.Serialization.JsonPropertyName("claimsToSuppress")]
27+
# endif
28+
public List<string> ClaimsToSuppress { get; set; } = new List<string>();
29+
30+
/// <summary>
31+
/// The output object containing the current group configuration. It includes groupsToOverride, iamRolesToOverride, and preferredRole.
32+
/// </summary>
33+
[DataMember(Name = "groupOverrideDetails")]
34+
#if NETCOREAPP3_1
35+
[System.Text.Json.Serialization.JsonPropertyName("groupOverrideDetails")]
36+
# endif
37+
public GroupConfiguration GroupOverrideDetails { get; set; } = new GroupConfiguration();
38+
}
39+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Amazon.Lambda.CognitoEvents
2+
{
3+
/// <summary>
4+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html
5+
/// </summary>
6+
public class CognitoCreateAuthChallengeEvent : CognitoTriggerEvent<CognitoCreateAuthChallengeRequest, CognitoCreateAuthChallengeResponse>
7+
{
8+
}
9+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.Collections.Generic;
2+
using System.Runtime.Serialization;
3+
4+
namespace Amazon.Lambda.CognitoEvents
5+
{
6+
/// <summary>
7+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html
8+
/// </summary>
9+
public class CognitoCreateAuthChallengeRequest : CognitoTriggerRequest
10+
{
11+
/// <summary>
12+
/// One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the pre sign-up trigger. You can pass this data to your Lambda function by using the ClientMetadata parameter in the following API actions: AdminCreateUser, AdminRespondToAuthChallenge, ForgotPassword, and SignUp.
13+
/// </summary>
14+
[DataMember(Name = "clientMetadata")]
15+
#if NETCOREAPP3_1
16+
[System.Text.Json.Serialization.JsonPropertyName("clientMetadata")]
17+
# endif
18+
public Dictionary<string, string> ClientMetadata { get; set; } = new Dictionary<string, string>();
19+
20+
/// <summary>
21+
/// The name of the new challenge.
22+
/// </summary>
23+
[DataMember(Name = "challengeName")]
24+
#if NETCOREAPP3_1
25+
[System.Text.Json.Serialization.JsonPropertyName("challengeName")]
26+
#endif
27+
public string ChallengeName { get; set; }
28+
29+
/// <summary>
30+
/// an array of ChallengeResult elements
31+
/// </summary>
32+
[DataMember(Name = "session")]
33+
#if NETCOREAPP3_1
34+
[System.Text.Json.Serialization.JsonPropertyName("session")]
35+
#endif
36+
public List<ChallengeResultElement> Session { get; set; } = new List<ChallengeResultElement>();
37+
38+
/// <summary>
39+
/// A Boolean that is populated when PreventUserExistenceErrors is set to ENABLED for your user pool client. A value of true means that the user id (user name, email address, etc.) did not match any existing users. When PreventUserExistenceErrors is set to ENABLED, the service will not report back to the app that the user does not exist. The recommended best practice is for your Lambda functions to maintain the same user experience including latency so the caller cannot detect different behavior when the user exists or doesn’t exist.
40+
/// </summary>
41+
[DataMember(Name = "userNotFound")]
42+
#if NETCOREAPP3_1
43+
[System.Text.Json.Serialization.JsonPropertyName("userNotFound")]
44+
#endif
45+
public bool UserNotFound { get; set; }
46+
}
47+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Collections.Generic;
2+
using System.Runtime.Serialization;
3+
4+
namespace Amazon.Lambda.CognitoEvents
5+
{
6+
/// <summary>
7+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-create-auth-challenge.html
8+
/// </summary>
9+
public class CognitoCreateAuthChallengeResponse : CognitoTriggerResponse
10+
{
11+
/// <summary>
12+
/// One or more key-value pairs for the client app to use in the challenge to be presented to the user.This parameter should contain all of the necessary information to accurately present the challenge to the user.
13+
/// </summary>
14+
[DataMember(Name = "publicChallengeParameters")]
15+
#if NETCOREAPP3_1
16+
[System.Text.Json.Serialization.JsonPropertyName("publicChallengeParameters")]
17+
#endif
18+
public Dictionary<string, string> PublicChallengeParameters { get; set; } = new Dictionary<string, string>();
19+
20+
/// <summary>
21+
/// This parameter is only used by the Verify Auth Challenge Response Lambda trigger. This parameter should contain all of the information that is required to validate the user's response to the challenge. In other words, the publicChallengeParameters parameter contains the question that is presented to the user and privateChallengeParameters contains the valid answers for the question.
22+
/// </summary>
23+
[DataMember(Name = "privateChallengeParameters")]
24+
#if NETCOREAPP3_1
25+
[System.Text.Json.Serialization.JsonPropertyName("privateChallengeParameters")]
26+
#endif
27+
public Dictionary<string, string> PrivateChallengeParameters { get; set; } = new Dictionary<string, string>();
28+
29+
/// <summary>
30+
/// Your name for the custom challenge, if this is a custom challenge.
31+
/// </summary>
32+
[DataMember(Name = "challengeMetadata")]
33+
#if NETCOREAPP3_1
34+
[System.Text.Json.Serialization.JsonPropertyName("challengeMetadata")]
35+
#endif
36+
public string ChallengeMetadata { get; set; }
37+
}
38+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Amazon.Lambda.CognitoEvents
2+
{
3+
/// <summary>
4+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-email-sender.html
5+
/// </summary>
6+
public class CognitoCustomEmailSenderEvent : CognitoTriggerEvent<CognitoCustomEmailSenderRequest, CognitoCustomEmailSenderResponse>
7+
{
8+
}
9+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Amazon.Lambda.CognitoEvents
4+
{
5+
/// <summary>
6+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-email-sender.html
7+
/// </summary>
8+
public class CognitoCustomEmailSenderRequest : CognitoTriggerRequest
9+
{
10+
/// <summary>
11+
/// The type of sender request.
12+
/// </summary>
13+
[DataMember(Name = "type")]
14+
#if NETCOREAPP3_1
15+
[System.Text.Json.Serialization.JsonPropertyName("type")]
16+
# endif
17+
public string Type { get; set; }
18+
19+
/// <summary>
20+
/// The encrypted temporary authorization code.
21+
/// </summary>
22+
[DataMember(Name = "code")]
23+
#if NETCOREAPP3_1
24+
[System.Text.Json.Serialization.JsonPropertyName("code")]
25+
#endif
26+
public string Code { get; set; }
27+
}
28+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Amazon.Lambda.CognitoEvents
2+
{
3+
/// <summary>
4+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-email-sender.html
5+
/// </summary>
6+
public class CognitoCustomEmailSenderResponse : CognitoTriggerResponse
7+
{
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Amazon.Lambda.CognitoEvents
2+
{
3+
/// <summary>
4+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
5+
/// </summary>
6+
public class CognitoCustomMessageEvent : CognitoTriggerEvent<CognitoCustomMessageRequest, CognitoCustomMessageResponse>
7+
{
8+
}
9+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Collections.Generic;
2+
using System.Runtime.Serialization;
3+
4+
namespace Amazon.Lambda.CognitoEvents
5+
{
6+
/// <summary>
7+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
8+
/// </summary>
9+
public class CognitoCustomMessageRequest : CognitoTriggerRequest
10+
{
11+
/// <summary>
12+
/// A string for you to use as the placeholder for the verification code in the custom message.
13+
/// </summary>
14+
[DataMember(Name = "codeParameter")]
15+
#if NETCOREAPP3_1
16+
[System.Text.Json.Serialization.JsonPropertyName("codeParameter")]
17+
#endif
18+
public string CodeParameter { get; set; }
19+
20+
/// <summary>
21+
/// The username parameter. It is a required request parameter for the admin create user flow.
22+
/// </summary>
23+
[DataMember(Name = "usernameParameter")]
24+
#if NETCOREAPP3_1
25+
[System.Text.Json.Serialization.JsonPropertyName("usernameParameter")]
26+
#endif
27+
public string UsernameParameter { get; set; }
28+
29+
/// <summary>
30+
/// One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the pre sign-up trigger. You can pass this data to your Lambda function by using the ClientMetadata parameter in the following API actions: AdminCreateUser, AdminRespondToAuthChallenge, ForgotPassword, and SignUp.
31+
/// </summary>
32+
[DataMember(Name = "clientMetadata")]
33+
#if NETCOREAPP3_1
34+
[System.Text.Json.Serialization.JsonPropertyName("clientMetadata")]
35+
#endif
36+
public Dictionary<string, string> ClientMetadata { get; set; } = new Dictionary<string, string>();
37+
}
38+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Amazon.Lambda.CognitoEvents
4+
{
5+
/// <summary>
6+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html
7+
/// </summary>
8+
public class CognitoCustomMessageResponse : CognitoTriggerResponse
9+
{
10+
/// <summary>
11+
/// The custom SMS message to be sent to your users. Must include the codeParameter value received in the request.
12+
/// </summary>
13+
[DataMember(Name = "smsMessage")]
14+
#if NETCOREAPP3_1
15+
[System.Text.Json.Serialization.JsonPropertyName("smsMessage")]
16+
#endif
17+
public string SmsMessage { get; set; }
18+
19+
/// <summary>
20+
/// The custom email message to be sent to your users. Must include the codeParameter value received in the request.
21+
/// </summary>
22+
[DataMember(Name = "emailMessage")]
23+
#if NETCOREAPP3_1
24+
[System.Text.Json.Serialization.JsonPropertyName("emailMessage")]
25+
#endif
26+
public string EmailMessage { get; set; }
27+
28+
/// <summary>
29+
/// The subject line for the custom message.
30+
/// </summary>
31+
[DataMember(Name = "emailSubject")]
32+
#if NETCOREAPP3_1
33+
[System.Text.Json.Serialization.JsonPropertyName("emailSubject")]
34+
#endif
35+
public string EmailSubject { get; set; }
36+
}
37+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Amazon.Lambda.CognitoEvents
2+
{
3+
/// <summary>
4+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-sms-sender.html
5+
/// </summary>
6+
public class CognitoCustomSmsSenderEvent : CognitoTriggerEvent<CognitoCustomSmsSenderRequest, CognitoCustomSmsSenderResponse>
7+
{
8+
}
9+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace Amazon.Lambda.CognitoEvents
4+
{
5+
/// <summary>
6+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-sms-sender.html
7+
/// </summary>
8+
public class CognitoCustomSmsSenderRequest : CognitoTriggerRequest
9+
{
10+
/// <summary>
11+
/// The type of sender request.
12+
/// </summary>
13+
[DataMember(Name = "type")]
14+
#if NETCOREAPP3_1
15+
[System.Text.Json.Serialization.JsonPropertyName("type")]
16+
#endif
17+
public string Type { get; set; }
18+
19+
/// <summary>
20+
/// The encrypted temporary authorization code.
21+
/// </summary>
22+
[DataMember(Name = "code")]
23+
#if NETCOREAPP3_1
24+
[System.Text.Json.Serialization.JsonPropertyName("code")]
25+
#endif
26+
public string Code { get; set; }
27+
}
28+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Amazon.Lambda.CognitoEvents
2+
{
3+
/// <summary>
4+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-sms-sender.html
5+
/// </summary>
6+
public class CognitoCustomSmsSenderResponse : CognitoTriggerResponse
7+
{
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Amazon.Lambda.CognitoEvents
2+
{
3+
/// <summary>
4+
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-define-auth-challenge.html
5+
/// </summary>
6+
public class CognitoDefineAuthChallengeEvent : CognitoTriggerEvent<CognitoDefineAuthChallengeRequest, CognitoDefineAuthChallengeResponse>
7+
{
8+
}
9+
}

0 commit comments

Comments
 (0)