feat: Phase 1 Week 1 - User Service Foundation#167
Draft
lakshayman wants to merge 1 commit intochore-take-to-prodfrom
Draft
feat: Phase 1 Week 1 - User Service Foundation#167lakshayman wants to merge 1 commit intochore-take-to-prodfrom
lakshayman wants to merge 1 commit intochore-take-to-prodfrom
Conversation
- Add User data model with role-based access (ADMIN, DEVELOPER, VIEWER)
- Implement password hashing with bcrypt
- Create user registration endpoint (POST /users/register)
- Create user login endpoint (POST /users/login) with JWT token generation
- Add user profile management endpoints (GET/PUT /users/{userId})
- Extend JWT utils to support private key loading from SSM for token generation
- Add user table creation to DynamoDB setup script with email-index GSI
- Add request/response models for user operations
- Update SAM template with new Lambda functions and IAM policies
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Date: 16 Jan 2025
Developer Name: @lakshayman
Description
This PR implements Phase 1, Week 1: User Service Foundation for the Feature Flag Backend. It establishes a standalone user authentication system, enabling the service to manage users independently without relying on external RDS authentication.
Key Features Implemented:
User Data Model
Usermodel with fields: id, email, passwordHash, role, createdAt, updatedAt, isActiveADMIN,DEVELOPER,VIEWERPassword Security
HashPassword()andCheckPasswordHash()functions for secure password managementUser Registration Endpoint
POST /users/register- Register new usersUser Login Endpoint
POST /users/login- Authenticate users and generate JWT tokensUser Profile Management
GET /users/{userId}- Retrieve user profile (excludes password hash)PUT /users/{userId}- Update user profile (email, role, isActive status)JWT Token Generation
JWTUtilsto support private key loading from SSM Parameter StoreGenerateToken()method for creating JWT tokensInfrastructure Updates
setup-dynamodb-tables.shwith email-index GSIRegisterUserFunction,LoginUserFunction,GetUserByIdFunction, andUpdateUserFunctionto SAM templateDocumentation Updated?
Under Feature Flag
Database Changes
Database Changes:
usertable with partition keyidand GSI onemailfieldBreaking Changes
Development Tested?
Testing:
Screenshots
Screenshot 1
Test Coverage
Test Coverage Details
Additional Notes
Setup Requirements
DynamoDB Table Creation:
./setup-dynamodb-tables.sh
This will create the
usertable with email-index GSI.SSM Parameter Setup:
Private keys need to be stored in SSM Parameter Store:
PROD_RDS_BACKEND_PRIVATE_KEY(for production)STAGING_RDS_BACKEND_PRIVATE_KEY(for staging)The public key should already exist from previous setup.
API Endpoints:
POST /users/register- No authentication requiredPOST /users/login- No authentication requiredGET /users/{userId}- JWT authentication requiredPUT /users/{userId}- JWT authentication requiredNext Steps (Week 2)
Security Considerations
Files Changed
layer/models/user.go(new)layer/utils/password.go(new)layer/utils/RequestResponse.go(updated)layer/utils/Constants.go(updated)layer/utils/ErrorOutput.go(updated)layer/jwt/jwt.go(updated)registerUser/main.go(new)loginUser/main.go(new)getUserById/main.go(new)updateUser/main.go(new)setup-dynamodb-tables.sh(updated)template.yaml(updated)go.mod(updated)