GeezerVison is showing github.com — [improve][client] PIP-478: Athenz and SASL v5 authentication plugins (Personal CI) by lhotari · Pull Request #251 · lhotari/pulsar
Conversation
Personal CI run — not for merge. Base is pulsar-pip478-plugins-ci-base, a snapshot of lh-pip-478-core-migration-v2 (apache#26282), so the diff shows only this part.
PIP: apache#25890 (pip/pip-478.md)
Motivation
The fourth implementation part of PIP-478: migrate the two remaining built-in authentication plugins — Athenz and SASL — onto the asynchronous v5 SPI.
SASL is the interesting one. It is multi-round on both transports, and SaslAuthenticationV5 is the first production implementor of the framework HTTP authentication driver the core migration added — the piece that makes HttpAuthenticationDriver / AsyncHttpAuthenticationProvider live rather than an unused extension point.
Modifications
| Commit |
Change |
ed3357140e8 |
AthenzAuthenticationV5 (single-pass role token, both transports) and SaslAuthenticationV5 (BinaryAuthDataProvider + BinaryAuthChallengeHandler for the binary protocol, HttpAuthChallengeHandler + HttpAuthHeadersProvider for SASL-over-HTTP). The v4 shims keep their synchronous surface and drive the v5 bodies. |
3ef4f60452f |
Review fixes — see below. |
Review fixes (Fable + Codex gpt-5.6-sol)
JaxRsChallengeTransport leaked every successfully-completed Response. InvocationCallback hands the caller an unclosed response, and reading only its headers neither consumes the entity nor releases the connection — so the success branch leaked one pooled connection per authentication round while only the timed-out branch closed. The driver runs at least one round on every admin request, so this was per request, not per client.
AuthenticationSasl.client / saslRoleToken were plain fields written on the application thread and read from Jersey continuation threads. Both are volatile now, matching the neighbouring PIP-478 fields.
- The v5 builder wrapped these plugins, and
capability(...) reports only directly-implemented interfaces — so wrapping dropped HttpAuthHeadersProvider, made hasDataForHttp() false, and sent every http:// lookup out unauthenticated, while re-driving the plugin's deprecated synchronous surface. A v4 plugin implementing AsyncAuthenticationDriver now runs raw; genuinely-legacy plugins stay wrapped so their credential work is still off-loaded.
Verifying this change
:pulsar-client-auth-athenz:test, :pulsar-client-auth-sasl:test, :pulsar-client-v5:test pass; compileJava compileTestJava rat spotlessCheck checkstyleMain checkstyleTest pass.
- The raw-driving decision is mutation-verified: removing the branch fails
PulsarClientBuilderV5Test#aV4PluginDrivingItsOwnV5BodyRunsRawRatherThanWrapped, and a companion test pins that a legacy plugin stays wrapped.
Known follow-ups (not in this PR)
- A poisoned cached SASL role token is never invalidated when the broker returns a 401 without SASL headers (signer-secret rotation, divergent broker secrets), costing 10 wasted rounds per request until close. Worse in v4, but worth fixing.
- No test yet for the binary-transport SASL v5 body; the current suite is HTTP-only.
- The blocking auth executor's
AbortPolicy under burst, and wrap()'s name-based routing for third-party multi-round v4 plugins — both on the merged core migration, both for a separate PR.
Prepared with the assistance of Claude Code (Opus 5).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Migrate the two remaining built-in authentication plugins onto the asynchronous v5 SPI.
- AthenzAuthenticationV5 serves the role token as a single-pass credential over both transports;
the v4 AuthenticationAthenz keeps its synchronous surface and drives this body.
- SaslAuthenticationV5 implements the multi-round handshake: BinaryAuthDataProvider plus
BinaryAuthChallengeHandler for the binary protocol, and HttpAuthChallengeHandler plus
HttpAuthHeadersProvider for SASL-over-HTTP. This is the first production implementor of the
framework HTTP authentication driver added by the core migration.
Cherry-picked from the PIP-478 series branch and rebased onto the core migration.
Assisted-by: Claude Code (Opus 5)
… state, and raw-driving the shims
Review (Fable + Codex gpt-5.6-sol) of the Athenz/SASL v5 migration found three defects; the third
is what makes the new SASL path actually run on the v5 client.
- JaxRsChallengeTransport leaked every successfully-completed JAX-RS Response. InvocationCallback
hands the caller an unclosed response, and reading only its headers neither consumes the entity
nor releases the connection, so the success branch leaked one pooled connection per
authentication round while only the timed-out branch closed. The driver runs at least one round
on every admin request (round 0 replays the cached role token), so the leak was per request.
Completion and close now both go through completeAndClose(), which closes in a finally; toHeaders
is lifted alongside it. The class javadoc claimed leak-freedom and is corrected.
- AuthenticationSasl.client and saslRoleToken were plain fields, written by start()/close() on the
application thread and read from the challenge driver's Jersey continuation threads with no
happens-before edge. Both are volatile now, matching the treatment the neighbouring PIP-478
fields already had.
- PulsarClientBuilderV5 wrapped these plugins in V5ToV4AuthenticationAdapter. The v5
capability(...) contract reports only directly-implemented interfaces, so wrapping dropped
HttpAuthHeadersProvider, making hasDataForHttp() false and sending every http:// lookup out
unauthenticated — while also re-driving the plugin's deprecated synchronous surface. A v4 plugin
that implements AsyncAuthenticationDriver now runs raw: ClientCnx uses its async driver and
HttpClient finds AsyncHttpAuthenticationProvider on it. This covers Token, Basic, OAuth2 and
Athenz from the parent commits too, and keeps genuinely-legacy plugins wrapped so their
credential work is still off-loaded.
Mutation-verified: removing the raw-driving branch fails the new builder test.
Assisted-by: Claude Code (Opus 5)
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|