-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/upgrade to jwt route protection #11
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
Conversation
Move app/routes.py to app/routes/legacy_routes.py and rename function to register_legacy_routes(). Add app/__init__.py to centralize route registration. Register Blueprint in __init__.py. Improves modularity and prepares for future structure.
Includes duplicate email check, password hashing using bcrypt, and database insertion. Previously written registration tests now pass.
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.
Pull Request Overview
This PR introduces JWT-based authentication foundation by adding a new user registration endpoint and refactoring the application to use Flask-PyMongo. The changes prepare the system for future JWT authentication by establishing user management capabilities with secure password hashing.
- Added
/auth/registerendpoint with comprehensive validation and error handling - Integrated Flask-PyMongo extension and Flask-Bcrypt for secure password hashing
- Refactored route structure to separate authentication routes using Flask Blueprints
Reviewed Changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| app/init.py | Initialize Flask-PyMongo extension and register authentication blueprint |
| app/extensions.py | Create global PyMongo instance for shared database access |
| app/routes/auth_routes.py | Implement user registration endpoint with validation and password hashing |
| app/routes/legacy_routes.py | Rename route registration function for consistency |
| openapi.yml | Add OpenAPI documentation for user registration endpoint |
| tests/test_auth.py | Add comprehensive tests for registration endpoint scenarios |
| tests/conftest.py | Add users collection setup fixture and mongomock configuration |
| Multiple test files | Update import paths and function references after route refactoring |
| "password_hash": hashed_password.decode("utf-8"), | ||
| } | ||
| ).inserted_id | ||
| print(user_id) |
Copilot
AI
Aug 8, 2025
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.
The print statement should be removed from production code. Consider using proper logging instead if debugging information is needed.
| print(user_id) | |
| logging.info("Registered new user with id: %s", user_id) |
Fix spelling error Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fix spelling error 2 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fix spelling error 3 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fix spelling error 4 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
This PR introduces JWT-based authentication to the API, starting with a /auth/register endpoint to allow new users to sign up with securely hashed passwords. This sets the foundation for a future /auth/login endpoint that will generate JWTs for authenticated access to protected routes.
Key Changes
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Tests run with mocked MongoDB connection.
Verified responses match OpenAPI schema.
CI/CD
CURL
Added automated tests covering:
Checklist: