Skip to content

Conversation

@chawinkn
Copy link
Member

Changes

  • Added authMiddleware for protected-route using JWT
  • Added /api/auth/login for validate/login user from Keycloak and add to database if not exists

- create jwt utils
- update .env with jwt and keycloak base url
- create authMiddleware
- create login route
- basic create/find user repository
@chawinkn chawinkn requested a review from tonklaw October 25, 2025 18:41
@tonklaw tonklaw requested a review from Copilot October 25, 2025 21:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements authentication and Keycloak integration by adding JWT-based authentication middleware and a login endpoint that validates users against Keycloak and creates database records for new users.

Key Changes:

  • Implemented JWT utilities for signing, verifying, and decoding tokens
  • Created authentication flow with Keycloak OAuth2 password grant integration
  • Added protected route middleware using JWT token verification

Reviewed Changes

Copilot reviewed 14 out of 18 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/utils/jwt.ts JWT utility functions for token signing, verification, and Keycloak token decoding
src/usecase/auth/authUsecase.ts Business logic for user authentication, registration, and Keycloak user mapping
src/repository/user/userRepository.ts Database operations for user creation and existence checking
src/controller/auth/authController.ts HTTP request handler for login endpoint
src/middleware/authMiddleware.ts JWT authentication middleware for protected routes
src/middleware/errorHandler.ts Global error handling middleware
src/lib/api.ts Keycloak API client for token retrieval
src/router/authRouter.ts Router configuration for authentication endpoints
src/router/index.ts Integration of auth router into main routing
src/types/error/ApiError.ts Custom error class for API-related errors
src/app.ts Error handler middleware integration
prisma/schema.prisma User model and role/education level enums
package.json Added jsonwebtoken type definitions
.env.example Environment variable examples for JWT and Keycloak configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chawinkn chawinkn requested a review from Copilot October 26, 2025 06:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 14 out of 18 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chawinkn chawinkn changed the base branch from main to dev October 26, 2025 14:18
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