POST /api/login
Authenticates a user and sets an HTTP-only cookie for session management.Headers
Bearer token from Firebase authenticationFormat:
Bearer <firebase_jwt_token>Authentication
This endpoint uses Firebase JWT authentication. The JWT token is validated against:- Issuer:
https://securetoken.google.com/nxtspec - Audience:
nxtspec - Authority:
https://securetoken.google.com/nxtspec
Behavior
- Validates the Firebase JWT token from the Authorization header
- Extracts user information from the token
- Creates a new user record if the user doesn’t exist in the database
- Sets an HTTP-only secure cookie named
access_tokenwith the JWT token
Response
HTTP status code: 200 for success, 400 for bad request
Examples
Cookie Details
Theaccess_token cookie is set with the following properties:
- HttpOnly:
true(prevents JavaScript access) - Secure:
true(only sent over HTTPS) - SameSite:
Strict(prevents CSRF attacks)
The JWT token is stored in a secure HTTP-only cookie, making it inaccessible to JavaScript and protecting against XSS attacks.
POST /api/logout
Logs out the current user by deleting the authentication cookie.Authentication
No authentication required. The endpoint simply deletes theaccess_token cookie if it exists.
Response
HTTP status code: 200 for success
Examples
After logout, the
access_token cookie is deleted from the client. Any subsequent authenticated requests will fail until the user logs in again.