Skip to content

fix(entityresolution): pass inline claims through multi-strategy context - #3794

Open
jrschumacher wants to merge 5 commits into
mainfrom
fix/3790-resolve-entities-jwt-claims-context
Open

fix(entityresolution): pass inline claims through multi-strategy context#3794
jrschumacher wants to merge 5 commits into
mainfrom
fix/3790-resolve-entities-jwt-claims-context

Conversation

@jrschumacher

@jrschumacher jrschumacher commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

  • pass inline ResolveEntities claims through types.JWTClaimsContextKey before calling the multi-strategy service
  • add regression tests for both v1 and v2 claims-only ResolveEntities paths
  • normalize result values before building protobuf structs so metadata/claim arrays serialize cleanly

Testing

  • go test ./entityresolution/multi-strategy/...
  • golangci-lint run ./entityresolution/multi-strategy/...
  • cd sdk && go test -run TestREADMECodeBlocks

Fixes #3790

Summary by CodeRabbit

  • New Features

    • Multi-strategy entity resolution now supports inline JWT claims, including claim-to-entity field mapping and metadata.
    • Added BDD support and end-to-end scenarios for claims-based authorization, including permitted and denied access outcomes.
  • Bug Fixes

    • Improved normalization of claim and metadata values for reliable response formatting.
    • Claims context is only applied when provided by a claims entity.
  • Tests

    • Added unit and integration coverage for claims resolution, mappings, metadata, and authorization decisions.

@jrschumacher
jrschumacher requested a review from a team as a code owner July 28, 2026 19:38
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8fdde3a8-8496-409f-9124-408b7b903fd7

📥 Commits

Reviewing files that changed from the base of the PR and between 58f51ab and 4968d60.

📒 Files selected for processing (4)
  • service/entityresolution/multi-strategy/registration.go
  • service/entityresolution/multi-strategy/registration_test.go
  • service/entityresolution/multi-strategy/v2/registration.go
  • service/entityresolution/multi-strategy/v2/registration_test.go

📝 Walkthrough

Walkthrough

Multi-strategy ResolveEntities now passes inline JWT claims through context and converts claim and metadata values into protobuf-compatible results. Tests cover both registration paths and BDD authorization scenarios.

Changes

Claims-aware entity resolution

Layer / File(s) Summary
Claims context wiring and validation
service/entityresolution/multi-strategy/registration.go, service/entityresolution/multi-strategy/v2/registration.go, service/entityresolution/multi-strategy/*_test.go
Both ResolveEntities implementations inject computed claims into context. Tests verify claims-provider mapping and username failure behavior.
StructPB-compatible result values
service/entityresolution/multi-strategy/registration.go, service/entityresolution/multi-strategy/v2/registration.go
Claim and metadata values are converted through StructPBCompatibleValue before protobuf Struct construction.
Claims subject BDD support
tests-bdd/cukes/steps_authorization.go, tests-bdd/cukes/steps_authorization_test.go, tests-bdd/features/multi-strategy-ers-claims.feature
BDD steps convert plain JSON claims into protobuf Any values and verify permit and deny outcomes for inline claims subjects.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

Possibly related PRs

Suggested labels: comp:authorization

Suggested reviewers: elizabethhealy, pflynn-virtru

Poem

I carry claims through context today,
While protobuf shapes guide their way.
Engineering permits, marketing denies,
Rabbit-tested mappings reach the skies. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: passing inline claims through the multi-strategy resolution context.
Linked Issues check ✅ Passed The changes populate JWTClaimsContextKey before resolution and add regression coverage for the inline claims failure described in issue [#3790].
Out of Scope Changes check ✅ Passed The implementation, tests, and BDD coverage all support inline claims resolution and the requirements in issue [#3790].
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/3790-resolve-entities-jwt-claims-context

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/entityresolution/multi-strategy/registration.go`:
- Around line 449-473: The helper structPBCompatibleValue is duplicated in the
v2 package. Remove the duplicate implementation and reuse the existing shared or
canonical definition, updating callers as needed while preserving recursive
conversion of slices and maps.

In `@service/entityresolution/multi-strategy/v2/registration.go`:
- Around line 465-489: Remove the duplicate structPBCompatibleValue helper from
the v2 registration file and reuse the existing implementation from the v1
registration code through the established shared-access pattern. Preserve
recursive handling for []string, []interface{}, and map[string]interface{}
values without introducing another copy.
🪄 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 Plus

Run ID: 5e49ac7c-2bc3-4237-8a8a-4940e081f699

📥 Commits

Reviewing files that changed from the base of the PR and between 2bffa7f and 97c5210.

📒 Files selected for processing (4)
  • service/entityresolution/multi-strategy/registration.go
  • service/entityresolution/multi-strategy/registration_test.go
  • service/entityresolution/multi-strategy/v2/registration.go
  • service/entityresolution/multi-strategy/v2/registration_test.go

Comment thread service/entityresolution/multi-strategy/registration.go Outdated
Comment thread service/entityresolution/multi-strategy/v2/registration.go Outdated
Signed-off-by: Ryan Schumacher <jschumacher@virtru.com>
Signed-off-by: Ryan Schumacher <jschumacher@virtru.com>
Signed-off-by: Ryan Schumacher <jschumacher@virtru.com>
@jrschumacher
jrschumacher force-pushed the fix/3790-resolve-entities-jwt-claims-context branch from fccaf85 to 88c77a4 Compare July 29, 2026 13:48
@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.877366ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

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

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 409.622973ms
Throughput 244.13 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 51.447390301s
Average Latency 512.758904ms
Throughput 97.19 requests/second

Signed-off-by: Ryan Schumacher <jschumacher@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 217.394402ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

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

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 447.982549ms
Throughput 223.22 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 51.545646783s
Average Latency 513.918744ms
Throughput 97.00 requests/second

Comment thread service/entityresolution/multi-strategy/v2/registration_test.go
Signed-off-by: Ryan Schumacher <jschumacher@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 182.598692ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

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

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 406.49133ms
Throughput 246.01 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 48.378036522s
Average Latency 481.635395ms
Throughput 103.35 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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ers): ResolveEntities does not populate JWTClaimsContextKey for claims provider

2 participants