Core-Craft / Core-Craft/backend

System should maintain user session and store it in appropriate storage

Open
#59 0 comments 0 reactions 1 assignee Claimed by @mramitdas View on GitHub
enhancement good first issue
Dominant language
Python
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Here's a basic flow of how JWT authentication works with FastAPI:

User logs in: On a successful login, the server generates a JWT token and sends it to the client.
Client stores the JWT: The client should store the JWT token securely, such as in local storage or a secure cookie.
Subsequent requests: For every authenticated request, the client includes the JWT token in the Authorization header or through other means.
Server verifies the JWT: FastAPI (or your backend) validates the JWT token's signature and checks its expiration and other claims. If the token is valid, the request is considered authenticated.

If the session is not maintained when you refresh the page, here are a few things to check:

Token expiration: Ensure that the JWT token you issue has an appropriate expiration time (i.e., the "exp" claim). If the token expires too quickly, the user will be logged out upon token expiration.

Token storage: Make sure the client-side application (e.g., a web app) properly stores and sends the token on each request. If the token is lost or not sent with the request, the server won't recognize the user.

Check the server: Ensure that your FastAPI server is correctly configured to validate JWT tokens, and the logic for validating tokens is functioning as expected.

CORS settings: If you're making requests from a different domain or port, make sure your server's CORS (Cross-Origin Resource Sharing) settings are correctly configured to allow requests with the JWT token.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.