fix(sdk): use bearer auth for non-dpop Connect tokens - #3806
Conversation
Signed-off-by: strantalis <strantalis@virtru.com>
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe SDK adds atomic access-token credentials that include both the token and its authentication scheme. Token sources return Bearer or DPoP credentials. Connect uses the scheme to select authorization and DPoP generation. ChangesCredential scheme flow
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 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. Comment |
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@sdk/auth/token_adding_interceptor.go`:
- Around line 103-106: Update the token-selection flow in the interceptor to
obtain the access token and its DPoP/Bearer binding metadata through one atomic
credential-selection operation, rather than calling AccessToken() and
DPoPSupported() separately. Use that returned metadata to select the
Authorization scheme for the exact token, and add a concurrent-refresh
regression test covering both mismatched-binding cases.
🪄 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: 48a890e5-94d0-476e-8986-02187b92f80e
📒 Files selected for processing (7)
sdk/auth/access_token_source.gosdk/auth/token_adding_interceptor.gosdk/auth/token_adding_interceptor_test.gosdk/idp_access_token_source.gosdk/idp_cert_exchange.gosdk/idp_oauth_access_token_source.gosdk/idp_oauth_access_token_source_test.go
Address CodeRabbit's concurrent token-refresh finding by returning each access token with its DPoP status atomically. Signed-off-by: strantalis <strantalis@virtru.com>
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
dmihalcik-virtru
left a comment
There was a problem hiding this comment.
One optional (but large, maybe not worth it) change suggested
Signed-off-by: strantalis <strantalis@virtru.com>
d5641b1
There was a problem hiding this comment.
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 `@sdk/auth/access_token_source.go`:
- Around line 22-28: Normalize the OAuth token type comparison in
TokenTypeFromOAuthTokenType by using strings.EqualFold so any casing of DPoP
maps to TokenTypeDPoP; update sdk/auth/access_token_source.go lines 22-28.
Adjust the lowercase dpop test expectation in
sdk/auth/access_token_source_test.go lines 11-14 to expect TokenTypeDPoP.
In `@sdk/auth/token_adding_interceptor_test.go`:
- Around line 305-319: Update ConcurrentRefreshTokenSource so its
credential-fetch behavior is stateful: return credential on the first
AccessTokenCredential call and refreshed on the second, using suitable
synchronization if needed for concurrent access. Ensure the existing “when
refresh returns bearer” and “when refresh returns dpop” cases exercise the
refreshed credential and consume the refreshed field, while preserving the
initial credential behavior.
🪄 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: bca82a10-c252-48b8-b2aa-5260188d1078
📒 Files selected for processing (9)
sdk/auth/access_token_source.gosdk/auth/access_token_source_test.gosdk/auth/token_adding_interceptor.gosdk/auth/token_adding_interceptor_test.gosdk/idp_access_token_source.gosdk/idp_cert_exchange.gosdk/idp_oauth_access_token_source.gosdk/idp_oauth_access_token_source_test.gosdk/idp_token_exchange_token_source.go
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Signed-off-by: strantalis <strantalis@virtru.com>
X-Test Failure Reportopentdf |
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
|
dmihalcik-virtru
left a comment
There was a problem hiding this comment.
1 small optional change
🤖 I have created a release *beep* *boop* --- ## [0.28.0](opentdf/platform@sdk/v0.27.0...sdk/v0.28.0) (2026-08-03) ### Features * **sdk:** add AccessToken accessor to SDK ([opentdf#3775](opentdf#3775)) ([2911e22](opentdf@2911e22)) ### Bug Fixes * **sdk:** use bearer auth for non-dpop Connect tokens ([opentdf#3806](opentdf#3806)) ([4e140ac](opentdf@4e140ac)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
Summary
Use the OAuth token response's
token_typeto select Connect authentication:Authorization: Bearerand no DPoP proof for non-DPoP tokens.Authorization: DPoPand proof generation for DPoP-bound tokens.Why
The Connect interceptor unconditionally labeled every access token as DPoP. SaaS Audit uses a Bearer token contract and JSON Connect encoding, so its requests were rejected even when the token flow returned a Bearer token.
RFC 9449 makes
token_typethe authoritative signal for whether the issued token is DPoP-bound. Authorization-server discovery can advertise DPoP support, but does not establish the binding of an individual issued token.Validation
make fmtgo test ./...insdkgo test ./... -raceinsdkgolangci-lint run --new-from-rev=HEAD ./...insdkmake lintis blocked before code lint by an invalid local Buf API token. Rootmake testis blocked inlib/fixturesbecause Keycloak is unavailable atlocalhost:8888; the SDK race suite passed independently.Summary by CodeRabbit
New Features
Bug Fixes
Tests