Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement JWT Authentication and Return Token in Login Response #4

Merged
merged 14 commits into from
Jun 21, 2023
Merged

Implement JWT Authentication and Return Token in Login Response #4

merged 14 commits into from
Jun 21, 2023

Conversation

devAbreu
Copy link
Contributor

@devAbreu devAbreu commented Jun 20, 2023

Pull Request Description:

This pull request addresses the following issue:

This pull request introduces several key updates to the project:

  1. Implemented the express.json() middleware to handle JSON data. This middleware enhances the server's capability to parse incoming JSON payloads from requests, enabling seamless handling of JSON data throughout the application.

  2. Added a new route, /users, which serves as a test for private routes that require JWT tokens for authentication. This route provides an example of a protected endpoint that requires a valid JWT token for access.

  3. Integrated the dotenv package to facilitate loading sensitive data from the .env file. This approach enhances security by allowing the storage of environment-specific configurations and sensitive information (e.g., secret keys or database credentials) in a separate and secure location.

  4. Implemented logic to generate a JWT token when a user logs in. This logic handles the authentication process and returns a JWT token that can be utilized for subsequent authenticated requests.

  5. Added a userController router to facilitate testing of the verifyToken middleware. This router includes various endpoints related to user operations and serves as a demonstration of how the verifyToken middleware can be applied to protected routes.

  6. Created a userRoute file to define specific routes related to user operations. This file primarily focuses on the implementation of the verifyToken middleware to ensure that certain routes require valid JWT tokens for access.

  7. Developed the verifyToken middleware function, which authenticates the validity of the client's JWT token. This middleware function acts as a security measure by confirming the authenticity of the token before granting access to protected routes.

  8. Added the required dependencies, jsonwebtoken and dotenv, to facilitate token generation and the secure loading of sensitive environment-specific data, respectively.

These updates significantly enhance the security and functionality of the project, enabling the implementation of private routes that require valid JWT tokens for authentication.

@viralRupani viralRupani merged commit fddd198 into Codepire:main Jun 21, 2023
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 JWT.
2 participants