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

Feature Request : Implement JWT Authentication for Backend with SQL Database #34

Open
SarveshAtawane opened this issue Jul 28, 2024 · 0 comments

Comments

@SarveshAtawane
Copy link

Description:
We need to add user authentication to our backend API using JWT and store user credentials in a SQL database.

  1. Set up a SQL database to store user information:

    • Create a 'users' table with fields for username, hashed password.
  2. Implement user registration endpoint:

    • Create a /register route
    • Accept username and password in the request body
    • Hash the password before storing it in the database
    • Use SQL INSERT query to add new user to the 'users' table
    • Return appropriate success/error messages
  3. Implement user login endpoint:

    • Create a /login route
    • Use SQL SELECT query to retrieve user credentials from the database
    • Verify provided password against the stored hashed password
    • Generate a JWT token upon successful authentication
    • Return the token in the response
  4. Create JWT authentication middleware:

    • Implement a function to verify JWT tokens
    • Create a dependency that can be used to protect routes
  5. Secure relevant API endpoints:

    • Apply the JWT authentication dependency to the /query route
    • Return appropriate error messages for unauthorized access attempts
@SarveshAtawane SarveshAtawane changed the title Feature Request:Implement JWT Authentication for Backend with SQL Database Feature Request : Implement JWT Authentication for Backend with SQL Database Jul 28, 2024
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

No branches or pull requests

1 participant