Skip to content

[WEB-10187] fix: log API activity only for authenticated keys - #10316

Merged
sriramveeraghanta merged 1 commit into
previewfrom
fix/web-10187-api-log-authenticated
Nov 16, 2026
Merged

sriramveeraghanta merged 1 commit into
previewfrom
fix/web-10187-api-log-authenticated

Conversation

@pablohashescobar

Copy link
Copy Markdown
Member

Description

APITokenLogMiddleware queued an activity log, with the full request and response bodies, for any request that carried an X-Api-Key header: on any path, and whether or not the key was valid. It runs outside DRF throttling.

  • APIKeyAuthentication marks the underlying request once a key has authenticated, and the middleware logs only marked requests.
  • Stored body and response_body are 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

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

  • New 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.py helper updated to set the marker. 6 passed; the new cases fail without the fix.
  • Suggested: call a public API endpoint with a valid key and confirm an activity log row appears; repeat with a made-up key and confirm none does.

References

  • WEB-10187

Created with Claude Code

… 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.
Copilot AI balanced review requested due to automatic review settings November 15, 2026 23:13
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ba5a55b2-26e3-4494-9e1c-4f2ff91af6f2
Commits

Reviewing files that changed from the base of the PR and between 290383d and 74bd7c8.

Files selected for processing: 4

  • apps/api/plane/api/middleware/api_authentication.py
  • apps/api/plane/middleware/logger.py
  • apps/api/plane/tests/unit/middleware/test_logger.py
  • apps/api/plane/tests/unit/middleware/test_logger_authenticated_only.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@makeplane

makeplane Bot commented Nov 15, 2026

Copy link
Copy Markdown

@pablohashescobar pablohashescobar changed the title [WEB-10187] fix(security): log API activity only for authenticated keys [WEB-10187] fix: log API activity only for authenticated keys Nov 16, 2026

@sriramveeraghanta sriramveeraghanta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sriramveeraghanta
sriramveeraghanta merged commit a6a6744 into preview Nov 16, 2026
19 of 21 checks passed
@sriramveeraghanta
sriramveeraghanta deleted the fix/web-10187-api-log-authenticated branch November 16, 2026 20:24
sriramveeraghanta pushed a commit that referenced this pull request Nov 16, 2026
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.
Pawel-Kranzberg pushed a commit to klazwi/pi-plane that referenced this pull request Nov 18, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants