-
Notifications
You must be signed in to change notification settings - Fork 213
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
feat: implement user session management with jwt and database persistence #1212
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure comprehensive testing of the session management system, especially edge cases like concurrent session access and token revocation.
Then make sure all test are passing(currently the CI is failing)
458ddad
to
b21aa38
Compare
183bb75
to
2940aa4
Compare
I have refactored the get_session_schema_data to function asynchronously to prevent latency. |
Description
This PR introduces a comprehensive user session management system. It allows users to see the different devices signed into their account -including their locations- and provides a way to log out from all or specific devices.
Features
The key enhancements include:
Active Session Tracking: Each issued JWT refresh token is stored in the database with associated metadata such as user ID, device details, IP address, expires_at, and location.
Session Revocation: Users can view and selectively revoke active sessions, enabling logout from specific devices without affecting other sessions.
Enhanced Security: By maintaining a centralized session store, compromised tokens can be individually invalidated, reducing potential security risks.
Regular DB Management: Every Sunday midnight, expired and revoked tokens are removed from the db.
Related Issue (Link to issue ticket)
#1061
Motivation and Context
Implementing session management enhances user experience by providing control over active sessions and improves security by allowing precise token invalidation. This aligns with best practices for authentication systems, addressing the current limitations where JWTs are stateless and lack centralized management.
How Has This Been Tested?
The following testing strategies were employed
Integration Tests: Simulated user authentication workflows to verify that session data is accurately recorded and managed.
Manual Testing: Performed using Postman to validate endpoints for session management, including edge cases like attempting to revoke already invalidated tokens.
Types of changes
Checklist: