Skip to content

chore/added angular cognito cloudfront#39

Open
hackmajoris wants to merge 2 commits into
mainfrom
chore/added-angular-cognito-cloudfront
Open

chore/added angular cognito cloudfront#39
hackmajoris wants to merge 2 commits into
mainfrom
chore/added-angular-cognito-cloudfront

Conversation

@hackmajoris
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR integrates AWS Cognito authentication with an Angular frontend and updates the backend to use Cognito User Pools Authorizer. The authentication architecture improvements are solid, but 3 critical defects block merge.

Critical Issues Requiring Fixes

Three blocking issues identified:

  1. DynamoDB attribute mapping error - Incorrect struct tag prevents user profile creation in post-confirmation trigger
  2. Conditional expression logic error - Prevents registration after first user due to incorrect PK-only check
  3. Hardcoded configuration exposure - Cognito User Pool IDs visible in client-side bundle (security risk)

Changes Overview

The PR successfully:

  • Migrates from custom JWT to AWS Cognito authentication
  • Implements Cognito User Pools Authorizer at API Gateway level
  • Adds Angular frontend with AWS Amplify integration
  • Creates CloudFront distribution for frontend hosting
  • Implements post-confirmation Lambda trigger for user profile creation

Please address the critical issues before merging.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.


⚠️ This PR contains more than 30 files. Amazon Q is better at reviewing smaller PRs, and may miss issues in larger changesets.

SignInOutput
} from 'aws-amplify/auth';
import { CognitoUser, SignUpRequest, SignInRequest, ConfirmSignUpRequest } from '../models';
import amplifyConfig from '../../../../amplify_outputs.json';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: Configuration file import from static JSON exposes sensitive IDs in client-side code. The hardcoded import of amplify_outputs.json at line 15 makes Cognito User Pool IDs visible to attackers, enabling reconnaissance and targeted attacks.1

Footnotes

  1. CWE-540: Inclusion of Sensitive Information in Source Code - https://cwe.mitre.org/data/definitions/540.html

TableName: aws.String(tableName),
Item: item,
// Use condition to prevent overwriting existing users
ConditionExpression: aws.String("attribute_not_exists(PK)"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: Incorrect condition expression blocks user profile creation. The expression attribute_not_exists(PK) will fail when any user exists because all users share PK="User". This prevents new user registration after the first user.

Suggested change
ConditionExpression: aws.String("attribute_not_exists(PK)"),
ConditionExpression: aws.String("attribute_not_exists(PK) AND attribute_not_exists(SK)"),

// UserProfile represents the DynamoDB user profile structure
type UserProfile struct {
PK string `dynamodbav:"PK"`
SK string `dynamodbav:"entity_id"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: Incorrect DynamoDB attribute tag causes data insertion failure. The struct field SK has tag dynamodbav:"entity_id" but DynamoDB operations expect SK as the sort key attribute name.

Suggested change
SK string `dynamodbav:"entity_id"`
SK string `dynamodbav:"SK"`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant