Enhance session and host authentication management#29
Merged
Conversation
- Added functions to manage session tokens, host secrets, and CSRF tokens in api.js. - Updated joinRoom, changeRole, setRoundConfig, startGame, startNextRound, and resetGame functions to utilize new authentication headers. - Integrated session token handling in the WebSocket connection. - Improved error handling and notifications for session management. - Refactored main.js to use new API functions for game actions. - Updated JoinRole component to persist host credentials after room creation. - Cleaned up DOM rendering logic for better readability and maintainability.
There was a problem hiding this comment.
Pull request overview
This PR enhances authentication and security for the Penny Game application by implementing session tokens, host credentials (secrets + CSRF tokens), and rate limiting. The changes introduce token-based authentication for both players and hosts, secure credential storage, and improved WebSocket security.
Key Changes:
- Added session token and CSRF token management on both backend and frontend
- Implemented rate limiting and connection limits for security
- Enhanced WebSocket authentication with token validation
- Refactored API calls to include authentication headers
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
api/app/routes.py |
Added session/CSRF token validation, rate limiting, and admin token authentication |
api/app/game_logic.py |
Implemented token issuance and validation functions |
api/app/models.py |
Added session_tokens and host_csrf_token fields to PennyGame model |
api/app/websocket.py |
Added session token validation for WebSocket connections and connection limits |
front-end/public/scripts/api.js |
Implemented token storage/retrieval and header building functions |
front-end/public/scripts/main.js |
Refactored to use new API functions with authentication |
front-end/src/components/JoinRole.astro |
Persists host credentials after room creation |
front-end/package-lock.json |
Updated dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Related Issues
Changes Made
Screenshots (if applicable)
How to Test
Checklist
Additional Context