Improve ACL 2.0 authorization context handling - #10925
Conversation
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR significantly improves ACL 2.0 authorization context handling for both remoting and gRPC protocols while preserving backward compatibility. The changes are well-structured with comprehensive test coverage.
Key improvements:
- Backward compatibility layer (
AuthorizationCompatibility): Gracefully handles legacy request shapes that may not have explicit authorization contexts, preventing breakage for existing deployments - Input validation:
requireResource()anddecodeRequiredBody()helpers ensure non-null/non-blank values and proper body decoding, closing potential bypass vectors - Extended request coverage: Many new request codes are now properly handled (BATCH_ACK_MESSAGE, QUERY_ASSIGNMENT, SET_MESSAGE_REQUEST_MODE, etc.)
- Security hardening: Retry topic validation against consumer group prevents authorization bypass; empty contexts now properly rejected when compatibility doesn't match
- Comprehensive tests: Excellent test coverage including edge cases for compatibility matching, null handling, and resource pattern validation
Overall: Solid improvement to the authorization system. The code is clean, well-tested, and maintains backward compatibility.
Automated review by github-manager-bot
| case RequestCode.VIEW_MESSAGE_BY_ID: | ||
| return isHistoricalTopicAbsent(request); | ||
| default: | ||
| return false; |
There was a problem hiding this comment.
The catch (Throwable ignored) block silently swallows all exceptions. This is a deliberate defensive pattern for backward compatibility, but consider adding a brief comment explaining why all throwables are caught (e.g., 'catch-all to avoid breaking existing request flows when compatibility detection itself fails'). This helps future maintainers understand the intent and not 'fix' it away.
| } | ||
|
|
||
| public void evaluate(List<AuthorizationContext> contexts) { | ||
| /** |
There was a problem hiding this comment.
The behavior change from silently allowing empty contexts to throwing AuthorizationException is a security improvement. However, this could affect existing deployments that rely on the old pass-through behavior. Consider noting this in the PR description or commit message as a breaking change for operators who have ACL enabled but send requests without proper context building.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #10925 +/- ##
=============================================
+ Coverage 48.45% 48.56% +0.10%
- Complexity 13588 13673 +85
=============================================
Files 1380 1381 +1
Lines 101196 101464 +268
Branches 13130 13187 +57
=============================================
+ Hits 49038 49276 +238
- Misses 46190 46193 +3
- Partials 5968 5995 +27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This PR improves ACL 2.0 authorization context handling for remoting and gRPC requests while preserving compatibility with existing request shapes.