Repository navigation
[fix][txn] Improve transaction admin checks - #26773
Merged
Merged
Conversation
The v3 transaction admin endpoints did not check access consistently with other admin endpoints: coordinator-wide reads did not require superuser access, and the topic-scoped transaction buffer and pending ack stats endpoints only validated topic ownership. - Require superuser access for listCoordinators, getCoordinatorStats (all or by id), getCoordinatorInternalStats, getTransactionMetadata and getSlowTransactions. - Check the GET_STATS topic operation before resolving the topic for the transaction buffer and pending ack stats endpoints. Roles with produce or consume permission on the topic keep access. - Update TransactionAndSchemaAuthZTest to cover these endpoints and remove the related TODOs. Roles without the required permission now get an authorization error (HTTP 401) from these endpoints. Assisted-by: Claude Code
lhotari
requested review from
Technoboy-,
dao-jun,
david-streamlio,
merlimat and
nodece
September 30, 2026 00:42
dao-jun
approved these changes
Sep 30, 2026
ascentstream-bot
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Oct 1, 2026
(cherry picked from commit c50739c)
ascentstream-bot
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Oct 2, 2026
(cherry picked from commit c50739c)
Radiancebobo
pushed a commit
to Radiancebobo/pulsar
that referenced
this pull request
Oct 8, 2026
crossoverJie
added a commit
to crossoverJie/pulsar-client-go
that referenced
this pull request
Oct 15, 2026
TestTxn_TCClient read transaction metadata through the raw admin HTTP helper (httpGet -> httpDo), which calls the plain-text web service without any credentials, so the broker authenticates it as the "anonymous" role. apache/pulsar#26773 ("Improve transaction admin checks", shipped in 4.2.5 and 5.0.0) added validateSuperUserAccess() to the transaction metadata admin endpoint (GET /admin/v3/transactions/transactionMetadata/{mostSigBits}/{leastSigBits}). The unauthenticated request is now rejected with HTTP 401, so transactionStats fails and the test panics on the nil stats map. Add an httpGetWithTLS helper that calls the TLS web service using the test client certificate, whose CN ("admin") is a super-user role in standalone.conf, and use it for the transaction metadata request. Verified against Pulsar 4.2.4, 4.2.5 and 5.0.0. Co-Authored-By: CodeBuddy Code <[email protected]>
nodece
pushed a commit
to apache/pulsar-client-go
that referenced
this pull request
Oct 20, 2026
…ior changes (#1545) * [fix][test] Make TestSetTopicAutoCreation tolerant of broker error message changes The test asserted exact broker error strings, which broke when Pulsar changed the messages: - apache/pulsar#25163 (shipped in 4.2.5) relaxed the non-partitioned autoTopicCreation override validation and changed the rejection text from "[defaultNumPartitions] is not allowed to be set when the type is non-partition." to "[defaultNumPartitions] must be null, 0 or 1 when the type is non-partitioned." - 5.0.0 changed the missing-tenant error from "Tenant does not exist" to "Namespace does not exist". Replace the single exact-match `errReason` with an `errReasons` slice and assert containment, so the test passes against both old and new broker versions instead of being brittle to broker wording changes. Verified against Pulsar 4.2.4, 4.2.5 and 5.0.0. Co-Authored-By: CodeBuddy Code <[email protected]> * [fix][test] Authenticate transaction metadata request as super-user TestTxn_TCClient read transaction metadata through the raw admin HTTP helper (httpGet -> httpDo), which calls the plain-text web service without any credentials, so the broker authenticates it as the "anonymous" role. apache/pulsar#26773 ("Improve transaction admin checks", shipped in 4.2.5 and 5.0.0) added validateSuperUserAccess() to the transaction metadata admin endpoint (GET /admin/v3/transactions/transactionMetadata/{mostSigBits}/{leastSigBits}). The unauthenticated request is now rejected with HTTP 401, so transactionStats fails and the test panics on the nil stats map. Add an httpGetWithTLS helper that calls the TLS web service using the test client certificate, whose CN ("admin") is a super-user role in standalone.conf, and use it for the transaction metadata request. Verified against Pulsar 4.2.4, 4.2.5 and 5.0.0. Co-Authored-By: CodeBuddy Code <[email protected]> * [fix][test] Make TestPartitionState tolerant of removed stats field apache/pulsar#26687 (PIP-379: Remove the classic Shared and Key_Shared dispatcher implementations, shipped in 5.0.0) removed consumersAfterMarkDeletePosition from the subscription stats. The broker no longer serializes the field, so it unmarshals to a nil map instead of the empty map the test asserted. Assert the map is empty, which holds both for the old behavior (empty map) and the new one (absent/nil). Verified against Pulsar 4.2.4, 4.2.5 and 5.0.0. Co-Authored-By: CodeBuddy Code <[email protected]> * [fix][test] Address review feedback on admin test helpers - httpGetWithTLS: give the HTTPS test client a 30s timeout so a stalled broker/network path cannot hang the test run. - TestSetTopicAutoCreation: replace the unchecked `err.(rest.Error)` type assertion (which panics on transport/TLS errors) with `require.ErrorAs`. Co-Authored-By: CodeBuddy Code <[email protected]> * [fix][test] Cache the TLS admin HTTP client in test helper Build the HTTPS client (key pair, CA pool) once via sync.Once and reuse it across calls instead of rebuilding it on every request. Co-Authored-By: CodeBuddy Code <[email protected]> --------- Co-authored-by: CodeBuddy Code <[email protected]>
nodece
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Nov 6, 2026
(cherry picked from commit c50739c)
nodece
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Nov 16, 2026
(cherry picked from commit c50739c)
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.
Motivation
The v3 transaction admin endpoints expose two kinds of information: coordinator-wide
data (coordinator list, coordinator stats and internal stats, transaction metadata and
slow transactions), which spans all tenants, and topic-scoped transaction buffer and
pending ack stats. Access checks for these endpoints were not consistent with other admin
endpoints: coordinator-wide reads did not require superuser access and the topic-scoped
stats endpoints only validated topic ownership, not the caller's permission on the topic.
Modifications
listCoordinators,getCoordinatorStats(all or by id),getCoordinatorInternalStats,getTransactionMetadataandgetSlowTransactions.GET_STATStopic operation before resolving the topic for the transactionbuffer and pending ack stats endpoints, in the same way as other topic stats endpoints.
Callers with
produceorconsumepermission on the topic keep access.TransactionAndSchemaAuthZTestto cover the expected access for these endpointsand remove the related TODOs.
Roles without the required permission now get an authorization error (HTTP 401) from
these endpoints.
Verifying this change
This change is covered by the updated
TransactionAndSchemaAuthZTest, which verifies thatcoordinator-wide reads are allowed for superusers and rejected for tenant admins and other
roles, and that the topic-scoped transaction stats endpoints require the
GET_STATStopicoperation.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes