Skip to content

A CDK Application containing Stacks that deploy necessary resources required to implement a real-time fraud detection and prevention system using Amazon Fraud Detector and Amazon Cognito.

License

Notifications You must be signed in to change notification settings

aws-samples/amazon-fraud-detector-with-cognito

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Fraud Prevention with Amazon Fraud Detector and Amazon Cognito

This application demostrates how to implement Amazon Fraud Detector along with Amazon Cognito User Pools with customized auth flows and utilizing Cognito Lambda triggers to implement friction in the registration process for users whose fraud risk score is medium.

For fraud risk scores low, users will be registered and confirmed automatically to the Cognito User Pool. For fraud risk score high the PreSignUp Lambda trigger will prevent the user from sign up.

This project contains AWS Cloud Development Kit (CDK) application that deploys all the AWS resources necessary to implement a real-time fraud detection system using Amazon Cognito's custom auth workflow.

architecture

Getting Started

Pre-requisites

Installation

  1. Clone this repository and change directory
git clone <repo_url> afd-cognito-demo
cd afd-cognito-demo
  1. Install the required CDK Modules
npm install --save
  1. Update the .env file with the necessary information. You will need to provide the AWS account number and region you wish to deploy this application to. You will also need information about Amazon Fraud Detector' detector name, version, event type name and entity type names that you created as part of the pre-requisites. For example
AWS_ACCOUNT_NUMBER=111122223333
AWS_REGION=us-east-1
AFD_DETECTOR_NAME=sample_detector
AFD_DETECTOR_VERSION=1
AFD_EVENT_TYPE=sample_registration
AFD_ENTITY_TYPE=sample_customer
  1. Confiure IAM policies in the config/policies.json file. This CDK project creates Lambda functions. In order for the Lambda functions to be able to access other AWS resources, such as Amazon Fraud Detector, Cognito User Pool, and DynamoDB table, it needs an IAM Role with the required permissions. You should add policy names in the policies.json file so that the CDK project can create the IAM Role with the policies.
{
    "policy_names":[
        "policy-name-1",
        "policy-name-2",
        "policy-name-2"
    ]
}

For the purposes of this project the following AWS Managed policies are sufficient.

service-role/AWSLambdaVPCAccessExecutionRole
AmazonCognitoPowerUser
AmazonDynamoDBFullAccess
AmazonFraudDetectorFullAccessPolicy

⚠️ Some of the policies specified above can be more permissive than desired. Please exercise caution and follow principles of least privileges while creating IAM Roles for your AWS resources.

  1. Bootstrap the CDK project by replacing the <account_number> and <region> with your AWS account number and region where you wish to deploy the project.
cdk bootstrap aws://<account_number>/<region>
  1. Synthesize an AWS Cloudfromation template from the CDK project
cdk synth --all
  1. Deploy the CDK Project
cdk deploy --all
  1. (Optional) If you have already deployed this CDK app but have made new changes, you can run the command below to see the changes
cdk diff

Cleaning up

To avoid incurring future charges, delete the resources created for the solution.

cdk destroy --all

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

A CDK Application containing Stacks that deploy necessary resources required to implement a real-time fraud detection and prevention system using Amazon Fraud Detector and Amazon Cognito.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published