fix(auth): reject partial API auth credentials instead of treating as anonymous#29240
fix(auth): reject partial API auth credentials instead of treating as anonymous#29240Akash504-ai wants to merge 1 commit into
Conversation
|
Welcome to Cal.diy, @Akash504-ai! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis pull request modifies error handling in the 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
|
This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active. |
What does this PR do?
Fixes an issue in OptionalApiAuthGuard where partially provided API auth credentials (only client ID or only client secret) were incorrectly treated as unauthenticated requests instead of invalid ones.
Previously:
Now:
This aligns the behavior with the existing comment and expected auth semantics: "optional means no auth is fine, but invalid auth must fail"
Why this change?
The current logic creates a subtle auth downgrade issue: Invalid or incomplete credentials are silently ignored and treated as if no auth was provided.
This can lead to unintended access in endpoints that assume: "If auth is present, it must be valid"
This PR ensures:
Behavior Change
Before:

After:

Changes
Mandatory Tasks
How should this be tested?
Send request with only
X_CAL_CLIENT_ID---> should return 401Send request with only
X_CAL_SECRET_KEY---> should return 401Send request with no auth ---> should be allowed (if endpoint uses OptionalApiAuthGuard)
Send valid credentials ---> should authenticate normally
No special env variables required beyond standard setup.
Checklist