Repository navigation
feat(sdk): DSPX-5640 negotiate DPoP htu style from server advertisement - #441
Draft
dmihalcik-virtru wants to merge 1 commit into
Draft
dmihalcik-virtru wants to merge 1 commit into
dmihalcik-virtru wants to merge 1 commit into
Conversation
The SDK always signed DPoP proofs with the full request URL as htu. The first DPoP servers (service v0.11.x, DSP 2.7.x) compare an RPC's htu against its procedure and reject a full URL, so a new Java client could not talk to an old server. Pick the htu style per server origin, mirroring the Go SDK (sdk/auth/dpop_mode.go): 1. unauthenticated GET /.well-known/opentdf-configuration; a dpop block's rfc9449 is authoritative, else a non-empty top-level dpop_signing_alg_values_supported means RFC 9449 (service v0.18.0+), 2. else RFC 9728 /.well-known/oauth-protected-resource with that key, 3. else legacy. Only definitive answers are cached: a non-5xx answer from the opentdf well-known (a 4xx or an unparseable 200 means not advertised) or an RFC 9728 advertisement. A network error or 5xx on the well-known step uses legacy for that request only, logs a warning, and is retried on the next request. The platform origin is seeded from the bootstrap well-known response when it advertises, so the common case makes no extra requests. Legacy keeps the DPoP Authorization scheme, ath and nonce handling; only the htu changes, to the procedure (/pkg.Service/Method, the last two path segments, dropping any proxy prefix). Non-RPC requests and token endpoint proofs keep the full URI, and non-DPoP Bearer tokens are unaffected. SDKBuilder.dpopMode(AUTO | LEGACY | RFC9449; default AUTO) overrides discovery, matching Go's WithDPoPMode. Verified with mvn -pl sdk -am test (459 tests, 0 failures). DPoPModeTest covers each advertisement source, both, neither, transient failures not being cached, definitive 404 and unparseable answers being cached, bootstrap seeding, the override, and a nonce challenge in each mode. SDKBuilderTest now checks a seeded platform signs the full URL while a KAS with no well-known documents gets the procedure htu. Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
|
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Proposed Changes
Fixes DSPX-5640. Part of epic DSPX-5549 (DPoP RFC 9449 migration, step 2.1). The Go equivalent is opentdf/platform#4322 (DSPX-5639); both SDKs follow the same rules.
Problem. The SDK always signs DPoP proofs with the full request URL as
htu. The first DPoP servers (service v0.11.x, shipped in DSP 2.7.x) compare an RPC'shtuagainst its procedure path, so they reject every request from a current Java client.Fix. Pick the
htustyle per server origin from what the server advertises.GET /.well-known/opentdf-configuration: adpopblock'srfc9449is authoritative; otherwise a non-empty top-leveldpop_signing_alg_values_supportedmeans RFC 9449 (service v0.18.0 and later);/.well-known/oauth-protected-resourcewithdpop_signing_alg_values_supported;htu, to the procedure (/pkg.Service/Method, the last two path segments, dropping any proxy prefix). TheDPoPAuthorization scheme,athand nonce handling are unchanged: step-One servers accept theDPoPscheme, andstrict_schemeservers require it. Non-RPC requests and token-endpoint proofs keep the full URI. Plain Bearer tokens are unaffected.SDKBuilder.dpopMode(DPoPMode.AUTO | LEGACY | RFC9449), defaultAUTO. The existing publicTokenSourceconstructor stays fixed to RFC 9449.Testing
mvn -pl sdk -am test: 459 tests, 0 failures, 9 skipped (the existing FIPS and EC skips).DPoPModeTest(21 tests): each advertisement source, both, neither; transient failures not cached and rediscovered; definitive 404 and unparseable answers cached; bootstrap seeding; both overrides; proxy-prefix, non-RPC and short-pathhtu; a nonce challenge in each mode.SDKBuilderTestnow runs inAUTO. A seeded platform signs the full URL, while a KAS with no well-known documents gets the procedurehtu, both under theDPoPscheme.Checklist