diff --git a/.gitignore b/.gitignore index e1d20a2c4a..4b14254024 100755 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,17 @@ awsconfiguration.json #amplify amplify/\#current-cloud-backend amplify/.config/local-* +amplify/mock-data amplify/backend/amplify-meta.json +amplify/backend/awscloudformation +build/ +dist/ +node_modules/ aws-exports.js -awsconfiguration.json \ No newline at end of file +awsconfiguration.json +amplifyconfiguration.json +amplify-build-config.json +amplify-gradle-config.json +amplifytools.xcconfig + +notes \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..c87b85ede7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "files.exclude": { + "amplify/.config": true, + "amplify/**/*-parameters.json": true, + "amplify/**/amplify.state": true, + "amplify/**/transform.conf.json": true, + "amplify/#current-cloud-backend": true, + "amplify/backend/amplify-meta.json": true, + "amplify/backend/awscloudformation": true + } +} \ No newline at end of file diff --git a/README.md b/README.md index df5705ff7c..6d2ef19af3 100755 --- a/README.md +++ b/README.md @@ -2,9 +2,7 @@ This auth starter implements withAuthenticator HOC to provide a basic authentication flow for signing up signing in users as well as protected client side routing using AWS Amplify. Auth features: User sign up, User sign in, Multi-factor Authentication, User sign-out. -[View Demo](https://master.d2ka7y7551sk8n.amplifyapp.com/) - - +[View Demo](https://apnacred.crediwatch.org/) ## Deploy with the AWS Amplify Console @@ -34,8 +32,6 @@ The Amplify Console will fork this repo in your GitHub account, and then build a amplify pull ``` - - 4. Run locally ``` diff --git a/amplify/.config/project-config.json b/amplify/.config/project-config.json old mode 100755 new mode 100644 index bafe837409..e5a81eae75 --- a/amplify/.config/project-config.json +++ b/amplify/.config/project-config.json @@ -1,17 +1,17 @@ { - "projectName": "authcra", - "version": "1.0", - "frontend": "javascript", - "javascript": { - "framework": "react", - "config": { - "SourceDir": "src", - "DistributionDir": "build", - "BuildCommand": "npm run-script build", - "StartCommand": "npm run-script start" - } - }, - "providers": [ - "awscloudformation" - ] + "providers": [ + "awscloudformation" + ], + "projectName": "accounts", + "version": "3.0", + "frontend": "javascript", + "javascript": { + "framework": "react", + "config": { + "SourceDir": "src", + "DistributionDir": "build", + "BuildCommand": "npm run-script build", + "StartCommand": "npm run-script start" + } + } } \ No newline at end of file diff --git a/amplify/backend/auth/cognitocf0c6096/cognitocf0c6096-cloudformation-template.yml b/amplify/backend/auth/cognitocf0c6096/cognitocf0c6096-cloudformation-template.yml index 4cfeebbb61..4ff768d31e 100755 --- a/amplify/backend/auth/cognitocf0c6096/cognitocf0c6096-cloudformation-template.yml +++ b/amplify/backend/auth/cognitocf0c6096/cognitocf0c6096-cloudformation-template.yml @@ -263,7 +263,7 @@ Resources: - ' }' - '};' Handler: index.handler - Runtime: nodejs8.10 + Runtime: nodejs10.x Timeout: '300' Role: !GetAtt - UserPoolClientRole diff --git a/amplify/backend/auth/userPoolGroups/parameters.json b/amplify/backend/auth/userPoolGroups/parameters.json new file mode 100644 index 0000000000..48115bd5cd --- /dev/null +++ b/amplify/backend/auth/userPoolGroups/parameters.json @@ -0,0 +1,14 @@ +{ + "AuthRoleArn": { + "Fn::GetAtt": [ + "AuthRole", + "Arn" + ] + }, + "UnauthRoleArn": { + "Fn::GetAtt": [ + "UnauthRole", + "Arn" + ] + } +} \ No newline at end of file diff --git a/amplify/backend/auth/userPoolGroups/template.json b/amplify/backend/auth/userPoolGroups/template.json new file mode 100644 index 0000000000..3530aa485f --- /dev/null +++ b/amplify/backend/auth/userPoolGroups/template.json @@ -0,0 +1,311 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Parameters": { + "authcognitocf0c6096UserPoolId": { + "Type": "String", + "Default": "authcognitocf0c6096UserPoolId" + }, + + "authcognitocf0c6096IdentityPoolId": { + "Type": "String", + "Default": "authcognitocf0c6096IdentityPoolId" + }, + + "authcognitocf0c6096AppClientID": { + "Type": "String", + "Default": "authcognitocf0c6096AppClientID" + }, + "authcognitocf0c6096AppClientIDWeb": { + "Type": "String", + "Default": "authcognitocf0c6096AppClientIDWeb" + }, + "AuthRoleArn": { + "Type": "String" + }, + "UnauthRoleArn": { + "Type": "String" + }, + "env": { + "Type": "String" + } + }, + "Conditions": { + "ShouldNotCreateEnvResources": { + "Fn::Equals": [ + { + "Ref": "env" + }, + "NONE" + ] + } + }, + "Resources": { + + "apnacredGroup": { + "Type" : "AWS::Cognito::UserPoolGroup", + "Properties" : { + "GroupName" : "apnacred", + "Precedence" : 1, + + "RoleArn" : { + "Fn::GetAtt": [ + "apnacredGroupRole", + "Arn" + ] + }, + + "UserPoolId" : { + "Ref": "authcognitocf0c6096UserPoolId" + } + } + }, + + "apnacredGroupRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "RoleName":{ + "Fn::Join": [ + "", + [ + { + "Ref": "authcognitocf0c6096UserPoolId" + }, + "-apnacredGroupRole" + ] + ] + }, + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "", + "Effect": "Allow", + "Principal": { + "Federated": "cognito-identity.amazonaws.com" + }, + "Action": "sts:AssumeRoleWithWebIdentity", + "Condition": { + "StringEquals": {"cognito-identity.amazonaws.com:aud": {"Ref":"authcognitocf0c6096IdentityPoolId"}}, + "ForAnyValue:StringLike": {"cognito-identity.amazonaws.com:amr": "authenticated"} + } + } + ] + } + } + }, + + + + "LambdaExecutionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "RoleName": { + "Fn::If": [ + "ShouldNotCreateEnvResources", + { + + }, + { + + "Fn::Join": [ + "", + [ + + "cognitocf0c6096", + "-ExecutionRole-", + { + "Ref": "env" + } + ] + ] + } + ] + }, + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + }, + "Action": [ + "sts:AssumeRole" + ] + } + ] + }, + "Policies": [ + { + "PolicyName": "UserGroupLogPolicy", + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Resource": "arn:aws:logs:*:*:*" + } + ] + } + }, + { + "PolicyName": "UserGroupExecutionPolicy", + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "cognito-identity:SetIdentityPoolRoles", + "cognito-identity:ListIdentityPools", + "cognito-identity:describeIdentityPool" + + ], + "Resource": "*" + } + ] + } + }, + { + "PolicyName": "UserGroupPassRolePolicy", + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "iam:PassRole" + ], + "Resource": "*" + } + ] + } + } + ] + } + }, + "RoleMapFunction": { + "Type": "AWS::Lambda::Function", + "DependsOn": ["LambdaExecutionRole"], + "Properties": { + "Code": { + "ZipFile": { + "Fn::Join": [ + "\n", + [ + "const response = require('cfn-response');", + "const AWS = require('aws-sdk');", + "exports.handler = (event, context) => {", + "if (event.RequestType == 'Delete') {", + " response.send(event, context, response.SUCCESS, {message: 'Request type delete'})", + "};", + "if (event.RequestType == 'Create' || event.RequestType == 'Update') {", + " let { identityPoolId, appClientID, appClientIDWeb, userPoolId, region } = event.ResourceProperties;", + " try {", + " const cognitoidentity = new AWS.CognitoIdentity();", + " let params = {", + " IdentityPoolId: identityPoolId,", + " Roles: {", + " 'authenticated': event.ResourceProperties.AuthRoleArn,", + " 'unauthenticated': event.ResourceProperties.UnauthRoleArn,", + " },", + " RoleMappings: {}", + " };", + " if (appClientIDWeb) {", + " params.RoleMappings[`cognito-idp.${region}.amazonaws.com/${userPoolId}:${appClientIDWeb}`] = {", + " Type: 'Token',", + " AmbiguousRoleResolution: 'AuthenticatedRole',", + " }", + " }", + " if (appClientID) {", + " params.RoleMappings[`cognito-idp.${region}.amazonaws.com/${userPoolId}:${appClientID}`] = {", + " Type: 'Token',", + " AmbiguousRoleResolution: 'AuthenticatedRole',", + " }", + " }", + " cognitoidentity.setIdentityPoolRoles(params).promise();", + " response.send(event, context, response.SUCCESS, {message: 'Successfully updated identity pool.'})", + " } catch(err) {", + + " response.send(event, context, response.FAILED, {message: 'Error updating identity pool'});", + " }", + " };", + "};" + + ] + ] + } + }, + "Handler": "index.handler", + "Runtime": "nodejs10.x", + "Timeout": "300", + "Role": { + "Fn::GetAtt": [ + "LambdaExecutionRole", + "Arn" + ] + } + } + }, + "RoleMapFunctionInput": { + "Type": "Custom::LambdaCallout", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "RoleMapFunction", + "Arn" + ] + }, + "AuthRoleArn": { + "Ref": "AuthRoleArn" + }, + "UnauthRoleArn": { + "Ref": "UnauthRoleArn" + }, + "identityPoolId": { + "Ref": "authcognitocf0c6096IdentityPoolId" + }, + "userPoolId": { + "Ref": "authcognitocf0c6096UserPoolId" + }, + "appClientIDWeb": { + "Ref": "authcognitocf0c6096AppClientIDWeb" + }, + "appClientID": { + "Ref": "authcognitocf0c6096AppClientID" + }, + "region": { + "Ref": "AWS::Region" + }, + "env": { + "Ref": "env" + } + }, + "DependsOn": ["RoleMapFunction"] + } + + }, + + "Outputs": { + + "apnacredGroupRole": { + "Value": { + "Fn::GetAtt": [ + "apnacredGroupRole", + "Arn" + ] + } + + } + + + } + +} diff --git a/amplify/backend/auth/userPoolGroups/user-pool-group-precedence.json b/amplify/backend/auth/userPoolGroups/user-pool-group-precedence.json new file mode 100644 index 0000000000..9d444d75e6 --- /dev/null +++ b/amplify/backend/auth/userPoolGroups/user-pool-group-precedence.json @@ -0,0 +1,6 @@ +[ + { + "groupName": "apnacred", + "precedence": 1 + } +] \ No newline at end of file diff --git a/amplify/backend/backend-config.json b/amplify/backend/backend-config.json index 52c28f28b8..0a3bb958d2 100755 --- a/amplify/backend/backend-config.json +++ b/amplify/backend/backend-config.json @@ -1,8 +1,24 @@ { - "auth": { - "cognitocf0c6096": { - "service": "Cognito", - "providerPlugin": "awscloudformation" - } - } + "auth": { + "cognitocf0c6096": { + "service": "Cognito", + "providerPlugin": "awscloudformation" + }, + "userPoolGroups": { + "service": "Cognito-UserPool-Groups", + "providerPlugin": "awscloudformation", + "dependsOn": [ + { + "category": "auth", + "resourceName": "cognitocf0c6096", + "attributes": [ + "UserPoolId", + "AppClientIDWeb", + "AppClientID", + "IdentityPoolId" + ] + } + ] + } + } } \ No newline at end of file diff --git a/amplify/team-provider-info.json b/amplify/team-provider-info.json new file mode 100644 index 0000000000..38d12c58a4 --- /dev/null +++ b/amplify/team-provider-info.json @@ -0,0 +1,20 @@ +{ + "devy": { + "awscloudformation": { + "AuthRoleName": "amplify-authcra-devy-102224-authRole", + "UnauthRoleArn": "arn:aws:iam::650238549946:role/amplify-authcra-devy-102224-unauthRole", + "AuthRoleArn": "arn:aws:iam::650238549946:role/amplify-authcra-devy-102224-authRole", + "Region": "ap-south-1", + "DeploymentBucketName": "apnacred", + "UnauthRoleName": "amplify-authcra-devy-102224-unauthRole", + "StackName": "amplify-authcra-devy-102224", + "StackId": "arn:aws:cloudformation:ap-south-1:650238549946:stack/amplify-authcra-devy-102224/c4f0bec0-36e3-11eb-9692-0a70d351c9a0", + "AmplifyAppId": "d1ylh52h8ld25u" + }, + "categories": { + "auth": { + "cognitocf0c6096": {} + } + } + } +} \ No newline at end of file diff --git a/credentials.csv b/credentials.csv new file mode 100644 index 0000000000..d415388e39 --- /dev/null +++ b/credentials.csv @@ -0,0 +1,2 @@ +IAM User Name,Smtp Username,Smtp Password +"ses-smtp-user.20201205-175404",AKIAZOZJ4365MZYWU3E3,BLqA+pm/YmlaJTm6b0oQlo9vqkbjUEsBbuxN6DbKfCGL \ No newline at end of file diff --git a/package.json b/package.json index bd123ff0f0..2230781266 100755 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "dependencies": { "aws-amplify": "^2.2.0", "aws-amplify-react": "^3.1.1", + "aws-amplify-react-custom-ui": "^1.2.2", "bootstrap": "^4.4.1", "kind-of": "^6.0.3", "lodash": "^4.17.19", diff --git a/public/index.html b/public/index.html index 73b2ecd7fc..e80de729f3 100755 --- a/public/index.html +++ b/public/index.html @@ -2,7 +2,7 @@
- + -