fix: Add authentication to various endpoints#10977
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAuthentication and authorization requirements are added across multiple API endpoints. The changes include adding authenticated user dependencies to endpoint signatures in chat, files, models, monitor, and registration modules, plus enforcing superuser-level access for user creation and implementing owner-based access control for file operations with path traversal prevention. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touchesImportant Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 2 warnings)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
❌ Your project status has failed because the head coverage (39.26%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #10977 +/- ##
==========================================
+ Coverage 32.92% 32.95% +0.02%
==========================================
Files 1387 1387
Lines 65420 65452 +32
Branches 9680 9680
==========================================
+ Hits 21540 21568 +28
- Misses 42782 42787 +5
+ Partials 1098 1097 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
|
||
| @router.post("/") | ||
| async def handle_messages(request: Request): | ||
| async def handle_messages(request: Request, current_user: CurrentActiveMCPUser): |
There was a problem hiding this comment.
I'm not sure this is allowed
There was a problem hiding this comment.
I've updated this to not require auth - which i think is safe. Look good now @ogabrielluiz ?
Co-Authored-By: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-Authored-By: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This pull request introduces several security and access control improvements across the API endpoints, primarily by enforcing user authentication and authorization checks. The changes ensure that sensitive operations and data are only accessible to authenticated users, and in some cases, to users with specific roles (e.g., superusers). Additionally, input validation has been strengthened to prevent security vulnerabilities such as path traversal attacks.
Authentication and Authorization Enforcement:
chat.py,files.py,models.py,monitor.py,users.py, andregistration.pynow require aCurrentActiveUseror superuser for access, preventing unauthorized actions such as viewing configuration, accessing build events, downloading files/images, and creating users. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Fine-Grained Access Control:
files.pynow verify that the requesting user owns the flow before allowing access, returning appropriate HTTP errors if access is denied. [1] [2]Input Validation and Security Hardening:
download_profile_pictureendpoint infiles.pyadds strict validation to prevent path traversal attacks by checking for invalid folder and file names and ensuring resolved paths remain within allowed directories.Role-Based Restrictions:
users.pynow requires superuser authentication, restricting account creation to authorized personnel only.General API Security Improvements:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.