fix(processor): EVO-1546 — WebSocket chat auth crash#111
Merged
Conversation
…auth fix Updates processor submodule to include: - fix(websocket): skip WS routes in EvoAuthMiddleware (403 block) - fix(websocket): remove .data on EvoAuthResponse in get_jwt_token_ws
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts EvoAuth middleware to bypass authentication for WebSocket chat endpoints and fixes a token validation call in the WebSocket chat route that incorrectly accessed a non‑existent .data attribute on EvoAuthResponse. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Instead of hardcoding
/api/v1/chat/ws/and/api/v1/chat/ws-live/inskip_prefixes, consider centralizing WebSocket-auth-exempt paths (e.g., a shared constant or config) so future WS endpoints don’t require touching the middleware logic. - Add a short code comment in
evo_auth.pyexplaining why WebSocket upgrade paths are skipped (handshake has no Authorization header and auth is done in the WS handler) to make this exception explicit for future maintainers.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of hardcoding `/api/v1/chat/ws/` and `/api/v1/chat/ws-live/` in `skip_prefixes`, consider centralizing WebSocket-auth-exempt paths (e.g., a shared constant or config) so future WS endpoints don’t require touching the middleware logic.
- Add a short code comment in `evo_auth.py` explaining why WebSocket upgrade paths are skipped (handshake has no Authorization header and auth is done in the WS handler) to make this exception explicit for future maintainers.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Summary
.dataAttributeError noget_jwt_token_ws()—EvoAuthResponsenao tem.dataRoot Cause
Bug 1 (middleware 403):
_should_skip()emevo_auth.pynao incluia paths WebSocket. O browser nao envia Authorization header no WS handshake, entao a middleware retornava 403. O WS handler ja faz auth interna via mensagem JSON.Bug 2 (.data crash):
chat_routes.pylinha 88 acessava(await auth_service.validate_token(token, "bearer")).datamasvalidate_token()retornaEvoAuthResponsediretamente (com.user), nao tem.data. CausavaAttributeErrorapos token ser validado com sucesso.Changes
evo-ai-processor-community/src/middleware/evo_auth.py/api/v1/chat/ws/e/api/v1/chat/ws-live/emskip_prefixesevo-ai-processor-community/src/api/chat_routes.py.dataemvalidate_token()callTotal: 2 linhas alteradas em 2 arquivos
Impact
Test plan
Summary by Sourcery
Fix WebSocket chat authentication failures and runtime crash when validating tokens in the WebSocket handler.
Bug Fixes: