Skip to content

Add Refresh Token & Expiring Access Token Authentication #20

@BEGINNERUSER-git

Description

@BEGINNERUSER-git

Currently, our authentication flow only uses a single long-lived JWT (access token), which may compromise security. This feature request aims to improve our authentication by:
Adding short-lived access tokens (e.g. 15 minutes)
Implementing refresh tokens (e.g. 7 days)
Creating a /refresh-token endpoint
Storing refresh tokens securely (in DB)
Creating a /logout route to revoke refresh tokens

Tasks:
Update .env with token expiry values
Modify User model to store refresh token
Issue both access and refresh tokens on login
Add /refresh-token endpoint to issue new access token
Add /logout endpoint to invalidate refresh token
Update auth middleware to check for expired tokens

Benefits
Improved security (short-lived access tokens)
Better user experience (no repeated logins)
Easy session management and logout support
Lays groundwork for token rotation or session invalidation

Metadata

Metadata

Labels

GSSoC'25Issue scoped for GSSoC 2025level2Easy/Intermediate: ~3–6 hours

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions