Skip to content

107 add authentication check to users route#129

Open
mehanana wants to merge 6 commits intomainfrom
107-Add-Authentication-Check-to-Users-Route
Open

107 add authentication check to users route#129
mehanana wants to merge 6 commits intomainfrom
107-Add-Authentication-Check-to-Users-Route

Conversation

@mehanana
Copy link
Contributor

ℹ️ Issue

Closes #107

📝 Description

Write a short summary of what you added. Why is it important? Any member of C4C should be able to read this and understand your contribution -- not just your team members.

Added authentication to the users lambda route to protect it from anyone accessing the endpoints.

Briefly list the changes made to the code:

  1. Created an auth.ts file to retrieve tokens and verify through cognito, and then determine if the user is an admin or not
  2. Updated each endpoint in handler.ts to check authorization of the user before running the business logic
  3. Updated both test files to mock authorization to ensure the endpoints will work.

✔️ Verification

What steps did you take to verify your changes work? These should be clear enough for someone to be able to clone the branch and follow the steps themselves.

Provide screenshots of any new components, styling changes, or pages.

Tests ran after authorization was added:
Screenshot 2026-02-11 170500
Screenshot 2026-02-11 170651

🏕️ (Optional) Future Work / Notes

Did you notice anything ugly during the course of this ticket? Any bugs, design challenges, or unexpected behavior? Write it down so we can clean it up in a future ticket!

@github-actions github-actions bot requested a review from bhuvanh66 February 11, 2026 22:08
github-actions bot added a commit that referenced this pull request Feb 11, 2026
Copy link
Collaborator

@nourshoreibah nourshoreibah left a comment

Choose a reason for hiding this comment

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

Awesome work with the auth logic!! Just a couple of tweaks here

"sourceMap": true
},
"include": ["*.ts"],
"include": ["*.ts", "test/test-cognito.ts"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this? I think *.ts catches it

NX_DB_PORT=5432,

COGNITO_USER_POOL_ID=us-east-2_CxTueqe6g
COGNITO_CLIENT_ID=570i6ocj0882qu0ditm4vrr60f
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally we shouldn't be pushing these for security. You can put them in .env on your local and git will ignore them

"@nestjs/typeorm": "^10.0.0",
"@types/pg": "^8.15.5",
"amazon-cognito-identity-js": "^6.3.5",
"aws-jwt-verify": "^5.1.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

GHA failure seems to have something to do with this package, i'd check on it/compare to PRs that are passing these checks


"@types/aws-lambda@^8.10.160":
version "8.10.160"
resolved "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.160.tgz"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah it looks like you have 2 package managers. we us npm instead of yarn! might be causing the CI failure

Copy link
Collaborator

Choose a reason for hiding this comment

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

to be clear, we don't need this lock file

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.

Add Authentication Check to Users Routes

2 participants