Skip to content

feat(authz): make v2 request limits configurable#3508

Closed
jakedoublev wants to merge 6 commits into
mainfrom
DSPX-3344-authz-v2-request-limits
Closed

feat(authz): make v2 request limits configurable#3508
jakedoublev wants to merge 6 commits into
mainfrom
DSPX-3344-authz-v2-request-limits

Conversation

@jakedoublev
Copy link
Copy Markdown
Contributor

@jakedoublev jakedoublev commented May 21, 2026

Make Authorization v2 request limits configurable by moving max-count validation from proto CEL to service-side config.

Summary by CodeRabbit

  • New Features

    • Request limits are now configurable per deployment, replacing hard-coded constraints on entity chains, attribute values, obligations, and bulk/multi-resource requests.
  • Documentation

    • Updated configuration documentation to describe the new configurable request limits settings.
  • Tests

    • Added comprehensive validation tests for request limit enforcement across all authorization endpoints.

Review Change Stack

Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Warning

Rate limit exceeded

@jakedoublev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 39 minutes and 59 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b09a4c8d-ef63-4999-ad67-31f4ff93864d

📥 Commits

Reviewing files that changed from the base of the PR and between a6a155c and a0a6004.

📒 Files selected for processing (2)
  • service/authorization/v2/authorization_test.go
  • service/authorization/v2/validation_test.go
📝 Walkthrough

Walkthrough

This pull request implements a configurable request limits system for authorization v2 RPC endpoints. Proto validation rules are relaxed to remove upper-bound constraints, shifting enforcement to the service layer where limits are configured and validated against incoming requests.

Changes

Request Limits Configuration and Enforcement

Layer / File(s) Summary
Configuration Schema and Validation
service/authorization/v2/config.go, service/authorization/v2/config_test.go
Introduces RequestLimitsConfig struct with validated integer fields for entity chains, attribute FQNs, obligations, resources, and decision requests. Config.Validate() now checks request limits; Config.LogValue() emits them. Config tests use a defaults helper and verify both valid and invalid limit configurations.
Proto Validation Rule Relaxation
service/authorization/v2/authorization.proto
Removes upper-bound CEL constraints from EntityIdentifier.entity_chain, Resource.AttributeValues.attribute_values, GetDecisionRequest.fulfillable_obligation_fqns, GetDecisionMultiResourceRequest.resources and fulfillable_obligation_fqns, and GetDecisionBulkRequest.decision_requests, while keeping lower-bound and URI-validity checks.
Request Validation Implementation
service/authorization/v2/validation.go
New module with five entry-point validators (validateGetDecisionRequest, validateGetEntitlementsRequest, validateGetDecisionMultiResourceRequest, validateGetDecisionBulkRequest) and four helper validators for entity identifiers, resources, and obligations. Each returns an invalid-argument error with the request path and "got/max" counts on violation.
RPC Handler Integration
service/authorization/v2/authorization.go
Early validation calls added to GetEntitlements, GetDecision, GetDecisionMultiResource, and GetDecisionBulk handlers immediately after request receive, before PDP initialization.
Authorization Service Tests Update
service/authorization/v2/authorization_test.go
Proto-level "too many" tests removed and renamed to assert proto validation succeeds for high counts. New test cases added for 51 obligations and 201+ decision requests to confirm proto relaxation.
Validation Test Suite
service/authorization/v2/validation_test.go
Comprehensive tests verifying default limit enforcement, custom limit configuration, nested error paths with indices, and handler-level integration for all four RPC methods.
User-Facing Documentation
docs/Configuring.md, docs/grpc/index.html, docs/openapi/authorization/v2/authorization.openapi.yaml, docs/openapi/entityresolution/v2/entity_resolution.openapi.yaml
Configuration guide documents request_limits settings. API documentation removes hardcoded limit statements and reflects new service-enforced semantics.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • c-r33d
  • elizabethhealy

Poem

🐰 Limits now dance on config's stage,
Where proto frees the outer cage,
Service guards with gentle care,
Each request checked, none unaware!
From chains to FQNs, all measured fair.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.04% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: making Authorization v2 request limits configurable instead of hard-coded in protobuf validation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch DSPX-3344-authz-v2-request-limits

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request migrates request limit validation for Authorization v2 from static Protocol Buffer CEL expressions to a configurable service-side implementation. This change enhances flexibility by allowing administrators to adjust request limits via configuration rather than requiring code changes, while maintaining strict validation of incoming requests.

Highlights

  • Migration of Validation Logic: Moved request limit validation from static Protocol Buffer CEL expressions to a more flexible service-side Go implementation.
  • Configurable Request Limits: Introduced RequestLimitsConfig to allow administrators to dynamically configure authorization request limits via service settings.
  • Documentation and Testing: Updated documentation and test suites to reflect the new validation approach and ensure coverage for the configurable limits.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: docs/openapi/**/* (2)
    • docs/openapi/authorization/v2/authorization.openapi.yaml
    • docs/openapi/entityresolution/v2/entity_resolution.openapi.yaml
  • Ignored by pattern: protocol/**/* (1)
    • protocol/go/authorization/v2/authorization.pb.go
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


CEL was strict and hard to change, Now limits have a wider range. Configured now with ease and grace, The service runs at better pace.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request transitions the authorization service from hardcoded request limits to configurable ones. Changes include removing CEL-based size constraints in the Protobuf definitions, adding a new request_limits configuration section, and implementing a dedicated validation layer to enforce these limits. Documentation and tests have been updated to reflect the shift from static to dynamic limits. Review feedback identified potential nil pointer dereferences in the new validation functions for entity identifiers and resources, which could lead to runtime panics if not addressed.

Comment thread service/authorization/v2/validation.go
Comment thread service/authorization/v2/validation.go
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 183.663546ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 92.97839ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 452.22783ms
Throughput 221.13 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 44.098583497s
Average Latency 439.593714ms
Throughput 113.38 requests/second

@jakedoublev jakedoublev changed the title feat(authorization): make v2 request limits configurable feat(authz): make v2 request limits configurable May 21, 2026
Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 185.143638ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 91.33042ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 413.144688ms
Throughput 242.05 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 43.933898385s
Average Latency 437.124348ms
Throughput 113.81 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 177.953611ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 97.840262ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 431.596394ms
Throughput 231.70 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 44.013247845s
Average Latency 438.174634ms
Throughput 113.60 requests/second

Make DecisionRequestFulfillableObligationFqnsMax require > 0 consistent
with all other request limits. Add boundary tests verifying exactly-at-limit
values pass validation.

Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 193.026286ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 102.375997ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 421.103509ms
Throughput 237.47 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 44.959170806s
Average Latency 447.861895ms
Throughput 111.21 requests/second

Add ErrInvalidRequestLimitConfig sentinel error and extract
requestLimitConfigError helper to reduce duplication. Also replace
context.Background() with t.Context() in validation tests.

Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
@jakedoublev jakedoublev marked this pull request as ready for review May 21, 2026 20:33
@jakedoublev jakedoublev requested review from a team as code owners May 21, 2026 20:33
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 147.719114ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 77.216054ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 407.327206ms
Throughput 245.50 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 41.54424279s
Average Latency 414.295905ms
Throughput 120.35 requests/second

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@service/authorization/v2/authorization_test.go`:
- Around line 661-677: Add a parallel test case to cover
GetDecisionMultiResourceRequest with 51 obligations: create a test entry
mirroring the existing single-request case (name like "multi-entity: registered
resource, action: create, resource: registered, obligations - 51") that builds a
&authzV2.GetDecisionMultiResourceRequest using the same
sampleRegisteredResourceFQN for the entity and resource, sampleActionCreate for
Action, and fiftyOneObligations for FulfillableObligationFqns; place it
alongside the other table-driven cases in authorization_test.go so the
multi-resource proto path (GetDecisionMultiResourceRequest and its
FulfillableObligationFqns) is exercised and the 51-obligation success behavior
is validated.

In `@service/authorization/v2/validation_test.go`:
- Around line 60-67: The tests in
Test_validateGetDecisionMultiResourceRequest_DefaultRequestLimit (and the other
ranges) only assert resource count limits for GetDecisionMultiResourceRequest
and miss exercising the FulfillableObligationFqns branch, so add assertions and
test cases that validate obligation FQNs are checked against the configured
limit and that the branch is bound to the correct config key; update the test
helper newDecisionMultiResourceRequestWithResourceCount (or add new fixtures) to
produce requests with non-empty FulfillableObligationFqns and add cases for
valid/invalid counts, and verify validateGetDecisionMultiResourceRequest returns
connect.CodeInvalidArgument with the expected error message when obligation FQNs
exceed the limit and passes when within limits.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5d29f2ca-57fb-488c-b7b6-98ec86fa7fb5

📥 Commits

Reviewing files that changed from the base of the PR and between baa1403 and a6a155c.

⛔ Files ignored due to path filters (1)
  • protocol/go/authorization/v2/authorization.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (11)
  • docs/Configuring.md
  • docs/grpc/index.html
  • docs/openapi/authorization/v2/authorization.openapi.yaml
  • docs/openapi/entityresolution/v2/entity_resolution.openapi.yaml
  • service/authorization/v2/authorization.go
  • service/authorization/v2/authorization.proto
  • service/authorization/v2/authorization_test.go
  • service/authorization/v2/config.go
  • service/authorization/v2/config_test.go
  • service/authorization/v2/validation.go
  • service/authorization/v2/validation_test.go

Comment thread service/authorization/v2/authorization_test.go
Comment thread service/authorization/v2/validation_test.go Outdated
Comment thread service/authorization/v2/config.go
Add proto and service-side tests for FulfillableObligationFqns on
GetDecisionMultiResourceRequest, which was previously untested.

Signed-off-by: jakedoublev <jake.vanvorhis@virtru.com>
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 174.522442ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 85.357996ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 425.959388ms
Throughput 234.76 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 42.238982207s
Average Latency 419.826652ms
Throughput 118.37 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • examples
  • otdfctl
  • sdk
  • service
  • lib/fixtures
  • tests-bdd

See the workflow run for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants