Skip to content

Commit fb38bd4

Browse files
Add clientMetadata to cognito triggers that support it (#256)
Co-authored-by: Bryan Moffatt <[email protected]>
1 parent b76bc6a commit fb38bd4

10 files changed

+43
-7
lines changed

events/cognito.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type CognitoEventUserPoolsHeader struct {
8888
type CognitoEventUserPoolsPreSignupRequest struct {
8989
UserAttributes map[string]string `json:"userAttributes"`
9090
ValidationData map[string]string `json:"validationData"`
91+
ClientMetadata map[string]string `json:"clientMetadata"`
9192
}
9293

9394
// CognitoEventUserPoolsPreSignupResponse contains the response portion of a PreSignup event
@@ -110,6 +111,7 @@ type CognitoEventUserPoolsPreAuthenticationResponse struct {
110111
// CognitoEventUserPoolsPostConfirmationRequest contains the request portion of a PostConfirmation event
111112
type CognitoEventUserPoolsPostConfirmationRequest struct {
112113
UserAttributes map[string]string `json:"userAttributes"`
114+
ClientMetadata map[string]string `json:"clientMetadata"`
113115
}
114116

115117
// CognitoEventUserPoolsPostConfirmationResponse contains the response portion of a PostConfirmation event
@@ -120,6 +122,7 @@ type CognitoEventUserPoolsPostConfirmationResponse struct {
120122
type CognitoEventUserPoolsPreTokenGenRequest struct {
121123
UserAttributes map[string]string `json:"userAttributes"`
122124
GroupConfiguration GroupConfiguration `json:"groupConfiguration"`
125+
ClientMetadata map[string]string `json:"clientMetadata"`
123126
}
124127

125128
// CognitoEventUserPoolsPreTokenGenResponse containst the response portion of a PreTokenGen event
@@ -131,6 +134,7 @@ type CognitoEventUserPoolsPreTokenGenResponse struct {
131134
type CognitoEventUserPoolsPostAuthenticationRequest struct {
132135
NewDeviceUsed bool `json:"newDeviceUsed"`
133136
UserAttributes map[string]string `json:"userAttributes"`
137+
ClientMetadata map[string]string `json:"clientMetadata"`
134138
}
135139

136140
// CognitoEventUserPoolsPostAuthenticationResponse contains the response portion of a PostAuthentication event
@@ -139,7 +143,8 @@ type CognitoEventUserPoolsPostAuthenticationResponse struct {
139143

140144
// CognitoEventUserPoolsMigrateUserRequest contains the request portion of a MigrateUser event
141145
type CognitoEventUserPoolsMigrateUserRequest struct {
142-
Password string `json:"password"`
146+
Password string `json:"password"`
147+
ClientMetadata map[string]string `json:"clientMetadata"`
143148
}
144149

145150
// CognitoEventUserPoolsMigrateUserResponse contains the response portion of a MigrateUser event
@@ -177,6 +182,7 @@ type CognitoEventUserPoolsChallengeResult struct {
177182
type CognitoEventUserPoolsDefineAuthChallengeRequest struct {
178183
UserAttributes map[string]string `json:"userAttributes"`
179184
Session []*CognitoEventUserPoolsChallengeResult `json:"session"`
185+
ClientMetadata map[string]string `json:"clientMetadata"`
180186
}
181187

182188
// CognitoEventUserPoolsDefineAuthChallengeResponse defines auth challenge response parameters
@@ -198,6 +204,7 @@ type CognitoEventUserPoolsCreateAuthChallengeRequest struct {
198204
UserAttributes map[string]string `json:"userAttributes"`
199205
ChallengeName string `json:"challengeName"`
200206
Session []*CognitoEventUserPoolsChallengeResult `json:"session"`
207+
ClientMetadata map[string]string `json:"clientMetadata"`
201208
}
202209

203210
// CognitoEventUserPoolsCreateAuthChallengeResponse defines create auth challenge response rarameters
@@ -219,6 +226,7 @@ type CognitoEventUserPoolsVerifyAuthChallengeRequest struct {
219226
UserAttributes map[string]string `json:"userAttributes"`
220227
PrivateChallengeParameters map[string]string `json:"privateChallengeParameters"`
221228
ChallengeAnswer interface{} `json:"challengeAnswer"`
229+
ClientMetadata map[string]string `json:"clientMetadata"`
222230
}
223231

224232
// CognitoEventUserPoolsVerifyAuthChallengeResponse defines verify auth challenge response parameters
@@ -247,6 +255,7 @@ type CognitoEventUserPoolsCustomMessageRequest struct {
247255
UserAttributes map[string]interface{} `json:"userAttributes"`
248256
CodeParameter string `json:"codeParameter"`
249257
UsernameParameter string `json:"usernameParameter"`
258+
ClientMetadata map[string]string `json:"clientMetadata"`
250259
}
251260

252261
// CognitoEventUserPoolsCustomMessageResponse contains the response portion of a CustomMessage event

events/testdata/cognito-event-userpools-create-auth-challenge.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
"challengeResult": true,
2424
"challengeMetadata": "metadata"
2525
}
26-
]
26+
],
27+
"clientMetadata": {
28+
"exampleMetadataKey": "example metadata value"
29+
}
2730
},
2831
"response": {
2932
"publicChallengeParameters": {

events/testdata/cognito-event-userpools-custommessage.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
"email_verified": false
1515
},
1616
"codeParameter": "####",
17-
"usernameParameter": "{username}"
17+
"usernameParameter": "{username}",
18+
"clientMetadata": {
19+
"exampleMetadataKey": "example metadata value"
20+
}
1821
},
1922
"response": {
2023
"smsMessage": "<custom message to be sent in the message with code parameter>",

events/testdata/cognito-event-userpools-define-auth-challenge.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
"challengeResult": true,
2323
"challengeMetadata": "metadata"
2424
}
25-
]
25+
],
26+
"clientMetadata": {
27+
"exampleMetadataKey": "example metadata value"
28+
}
2629
},
2730
"response": {
2831
"challengeName": "challengeName",

events/testdata/cognito-event-userpools-migrateuser.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
"clientId": "<apps client id>"
1010
},
1111
"request": {
12-
"password": "<password>"
12+
"password": "<password>",
13+
"clientMetadata": {
14+
"exampleMetadataKey": "example metadata value"
15+
}
1316
},
1417
"response": {
1518
"userAttributes": {

events/testdata/cognito-event-userpools-postauthentication.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"userAttributes" : {
1414
"email": "<email>",
1515
"phone_number": "<phone_number>"
16+
},
17+
"clientMetadata": {
18+
"exampleMetadataKey": "example metadata value"
1619
}
1720
},
1821
"response": {}

events/testdata/cognito-event-userpools-postconfirmation.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"userAttributes" : {
1313
"email": "<email>",
1414
"phone_number": "<phone_number>"
15+
},
16+
"clientMetadata": {
17+
"exampleMetadataKey": "example metadata value"
1518
}
1619
},
1720
"response": {}

events/testdata/cognito-event-userpools-presignup.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
"validationData": {
1717
"k1": "v1",
1818
"k2": "v2"
19-
}
19+
},
20+
"clientMetadata": {
21+
"exampleMetadataKey": "example metadata value"
22+
}
2023
},
2124
"response": {
2225
"autoConfirmUser": false,

events/testdata/cognito-event-userpools-pretokengen.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"groupsToOverride": ["group-A", "group-B", "group-C"],
1818
"iamRolesToOverride": ["arn:aws:iam::XXXXXXXXXXXX:role/sns_callerA", "arn:aws:iam::XXXXXXXXX:role/sns_callerB", "arn:aws:iam::XXXXXXXXXX:role/sns_callerC"],
1919
"preferredRole": "arn:aws:iam::XXXXXXXXXXX:role/sns_caller"
20+
},
21+
"clientMetadata": {
22+
"exampleMetadataKey": "example metadata value"
2023
}
2124
},
2225
"response": {

events/testdata/cognito-event-userpools-verify-auth-challenge.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
"privateChallengeParameters": {
2020
"secret": "11122233"
2121
},
22-
"challengeAnswer": "123xxxx"
22+
"challengeAnswer": "123xxxx",
23+
"clientMetadata": {
24+
"exampleMetadataKey": "example metadata value"
25+
}
2326
},
2427
"response": {
2528
"answerCorrect": true

0 commit comments

Comments
 (0)