-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds support for pretokengen event. * link to the cognito events README files. * Iam -> IAM * Updated sample data with dummy values copied from * fix json synx error
- Loading branch information
Showing
5 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Sample Function | ||
|
||
The following is a sample Lambda function that receives Amazon Cognito User Pools pre-token-gen event as an input and writes some of the record data to CloudWatch Logs. (Note that by default anything written to Console will be logged as CloudWatch Logs events.) | ||
|
||
Please see instructions for setting up the Cognito triggers at https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html . | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-lambda-go/lambda" | ||
"github.com/aws/aws-lambda-go/events" | ||
) | ||
|
||
func handler(event events.CognitoEventUserPoolsPreTokenGen) (events.CognitoEventUserPoolsPreTokenGen, error) { | ||
fmt.Printf("PreTokenGen of user: %s\n", event.UserName) | ||
event.Response.ClaimOverrideDetails.ClaimsToSupress = []string{"family_name"} | ||
return event, nil | ||
} | ||
|
||
func main() { | ||
lambda.Start(handler) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"version": "1", | ||
"triggerSource": "PreTokenGen", | ||
"region": "region", | ||
"userPoolId": "userPoolId", | ||
"userName": "userName", | ||
"callerContext": { | ||
"awsSdkVersion": "calling aws sdk with version", | ||
"clientId": "apps client id" | ||
}, | ||
"request": { | ||
"userAttributes": { | ||
"email": "email", | ||
"phone_number": "phone_number" | ||
}, | ||
"groupConfiguration": { | ||
"groupsToOverride": ["group-A", "group-B", "group-C"], | ||
"iamRolesToOverride": ["arn:aws:iam::XXXXXXXXXXXX:role/sns_callerA", "arn:aws:iam::XXXXXXXXX:role/sns_callerB", "arn:aws:iam::XXXXXXXXXX:role/sns_callerC"], | ||
"preferredRole": "arn:aws:iam::XXXXXXXXXXX:role/sns_caller" | ||
} | ||
}, | ||
"response": { | ||
"claimsOverrideDetails": { | ||
"claimsToAddOrOverride": { | ||
"attribute_key2": "attribute_value2", | ||
"attribute_key": "attribute_value" | ||
}, | ||
"claimsToSuppress": ["email"], | ||
"groupOverrideDetails": { | ||
"groupsToOverride": ["group-A", "group-B", "group-C"], | ||
"iamRolesToOverride": ["arn:aws:iam::XXXXXXXXXXXX:role/sns_callerA", "arn:aws:iam::XXXXXXXXX:role/sns_callerB", "arn:aws:iam::XXXXXXXXXX:role/sns_callerC"], | ||
"preferredRole": "arn:aws:iam::XXXXXXXXXXX:role/sns_caller" | ||
} | ||
} | ||
} | ||
} |