Repository navigation
[WEB-10187] fix: log API activity only for authenticated keys - #10316
Conversation
… bodies The API activity log is now written only for requests that authenticated with an API key, and the stored request and response bodies are truncated to a fixed length.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 19 minutes. View limit details
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. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
sriramveeraghanta
left a comment
There was a problem hiding this comment.
LGTM. Non-blocking: plane/app/middleware/api_authentication.py holds an unused duplicate APIKeyAuthentication without the marker. Consider deleting it so nobody wires it up and silently loses logging.
The API activity log is now written only for requests that authenticated with an API key, and the stored request and response bodies are truncated to a fixed length.
…ane#10316) The API activity log is now written only for requests that authenticated with an API key, and the stored request and response bodies are truncated to a fixed length. (cherry picked from commit bb466c1)
Description
APITokenLogMiddlewarequeued an activity log, with the full request and response bodies, for any request that carried anX-Api-Keyheader: on any path, and whether or not the key was valid. It runs outside DRF throttling.APIKeyAuthenticationmarks the underlying request once a key has authenticated, and the middleware logs only marked requests.bodyandresponse_bodyare truncated to 10 KB (characters) with a truncation marker.Stored fields and header redaction are unchanged.
Behavior change: requests with an invalid or expired key are no longer recorded in
APIActivityLog, and long bodies are truncated.Type of Change
Screenshots and Media (if applicable)
Test Scenarios
plane/tests/unit/middleware/test_logger_authenticated_only.py, through a real DRF view: a request whose key did not authenticate queues nothing; an authenticated one queues a log with truncated bodies.test_logger.pyhelper updated to set the marker. 6 passed; the new cases fail without the fix.References
Created with Claude Code