GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][broker] Check the original principal of proxied HTTP requests with its own authentication data by lhotari · Pull Request #26748 · apache/pulsar

Conversation

@lhotari

@lhotari lhotari commented Sep 29, 2026

Copy link
Copy Markdown
Member

Motivation

For requests that come through a proxy, the broker authorizes both the proxy role and the original principal. On the binary protocol, ServerCnx checks the original principal with AuthenticationDataForwarded when the proxy does not forward the client's credentials. On HTTP, AuthorizationService and PulsarWebResource checked the original principal with the request's authentication data, which is authenticated as the proxy. Authorization providers that resolve roles from the authentication data, such as MultiRolesTokenAuthorizationProvider, then evaluated the original principal with the roles of the proxy's token.

The tenant admin check for proxied requests (validateAdminAccessForTenantAsync) also had two inconsistencies. When the proxy role itself was a tenant admin, the original principal was not checked. When it was not, both roles had to be super users, so a tenant admin could not use a super-user proxy.

Modifications

  • AuthorizationService:
    • The original principal of a proxied request is checked with AuthenticationDataForwarded instead of the request's authentication data, and a subscription set on the request data is kept. This applies to super user, tenant, namespace, namespace and topic policy, topic, broker, cluster, and function, source and sink checks. The proxy role is still checked with the request's authentication data.
    • Add isSuperUserOrTenantAdmin(tenant, role, authData), which recognizes super users and tenant admins with the provider's own checks: validateTenantAdminAccess for PulsarAuthorizationProvider and its subclasses (which includes the additional roles of multi-role tokens), otherwise the provider's isSuperUser and isTenantAdmin. For PulsarAuthorizationProvider it also checks isTenantAdmin for the role itself, so a tenant admin whose request carries no token, such as a TLS-authenticated proxy, is still recognized.
  • PulsarWebResource:
    • The super user check uses the original principal's own authentication data (originalPrincipalAuthData()).
    • For proxied requests that need tenant admin access, the proxy role and the original principal must each be a super user or a tenant admin, using AuthorizationService#isSuperUserOrTenantAdmin. The original principal is checked with its own authentication data.
  • AuthenticationDataForwarded: add ofProxiedRequest(AuthenticationDataSource) and getProxiedRequestData(), so a provider can look at the proxied request without treating it as authenticated for the original principal. AuthenticationDataForwarded.INSTANCE is unchanged.
  • MultiRolesTokenAuthorizationProvider: for the original principal of a proxied request, the roles of a token in the request are used only when that token is valid and authenticates as the original principal. For example, a client token forwarded by a TLS-authenticated proxy. Otherwise only the original principal's own role is used.
  • PulsarAuthorizationProvider resolves roles as before.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • AuthorizationServiceTest#testOriginalPrincipalIsCheckedWithoutProxyAuthData: the original principal is checked with AuthenticationDataForwarded (keeping the subscription) for topic, namespace, policy, tenant, broker, cluster, super user and function, source and sink checks, and the proxy role with the request data.
  • AuthorizationServiceTest#testIsSuperUserOrTenantAdminUsesProviderAdminChecks: isSuperUserOrTenantAdmin recognizes super users and tenant admins, and not roles that are only allowed tenant operations.
  • MultiRolesTokenAuthorizationProviderTest#testProxiedHttpRequestUsesOnlyTheOriginalPrincipalToken (broker-common): only a valid token of the original principal adds roles; the proxy's token, another principal's token and an invalid token of the original principal add none.
  • MultiRolesTokenAuthorizationProviderTest#testTenantAdminRoleWithoutTokenIsRecognized (broker-common): a tenant admin role is recognized when the request carries no token.
  • MultiRolesTokenTlsProxyHttpTest (broker): for a proxy that authenticates with a TLS client certificate and forwards the client's headers, a forwarded token of the original principal adds its roles, a missing token or another subject's token adds none, and a tenant-admin proxy with no token can serve a tenant admin but not an ordinary original principal.
  • MultiRolesTokenAuthorizationProviderTest#testProxiedRequestsCheckOriginalPrincipalWithItsOwnRole (broker): through a proxy whose token carries additional roles, an ordinary original principal does not get those roles for super user, topic, namespace and tenant admin operations, while a proxy forwarding a super user or a tenant admin keeps working.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Public API: AuthenticationDataForwarded gains ofProxiedRequest(AuthenticationDataSource) and getProxiedRequestData(), and AuthorizationService gains isSuperUserOrTenantAdmin(String, String, AuthenticationDataSource). Custom authorization providers now receive AuthenticationDataForwarded for the original principal of proxied HTTP requests, as they already do on the binary protocol.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lhotari
[fix][broker] Check the original principal of proxied HTTP requests w…
eaf557b
…ith its own authentication data

For proxied HTTP requests, the broker checked the original principal with
the request authentication data, which is authenticated as the proxy.
Providers that resolve roles from the authentication data, such as
MultiRolesTokenAuthorizationProvider, then evaluated the original
principal with the roles of the proxy token.

- AuthorizationService: check the original principal of proxied requests
  with AuthenticationDataForwarded, keeping the subscription, for super
  user, tenant, namespace, namespace and topic policy, topic, broker,
  cluster, and function, source and sink checks. Add
  isSuperUserOrTenantAdmin, which uses the provider's own admin checks and
  also recognizes a tenant admin role when the request carries no token.
- AuthenticationDataForwarded: add ofProxiedRequest and
  getProxiedRequestData.
- MultiRolesTokenAuthorizationProvider: for the original principal of a
  proxied request, use the roles of a token in the request only when it
  authenticates as the original principal.
- PulsarWebResource: the super user check uses the original principal's
  own authentication data, and for proxied requests needing tenant admin
  access both the proxy role and the original principal must each be a
  super user or a tenant admin.

Assisted-by: Claude Code
@lhotari lhotari added this to the 5.0.0 milestone Sep 29, 2026
@lhotari lhotari added release/4.2.5 release/4.0.14 labels Sep 29, 2026
@lhotari
lhotari requested review from Technoboy-, dao-jun, david-streamlio, merlimat and nodece September 29, 2026 17:09
merlimat
merlimat approved these changes Sep 29, 2026
View reviewed changes
@lhotari
lhotari merged commit f0c9094 into apache:master Sep 29, 2026
44 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@SEPURI-SAI-KRISHNA SEPURI-SAI-KRISHNA mentioned this pull request Oct 1, 2026
[Bug] Multi-role does not forbid user if proxy superuser #24403
Open
2 of 3 tasks
ascentstream-bot pushed a commit to ascentstream/pulsar that referenced this pull request Oct 1, 2026
@lhotari
[fix][broker] Check the original principal of proxied HTTP requests w…
4cace42
…ith its own authentication data (apache#26748)

(cherry picked from commit f0c9094)
ascentstream-bot pushed a commit to ascentstream/pulsar that referenced this pull request Oct 2, 2026
@lhotari
[fix][broker] Check the original principal of proxied HTTP requests w…
564835c
…ith its own authentication data (apache#26748)

(cherry picked from commit f0c9094)
Radiancebobo pushed a commit to Radiancebobo/pulsar that referenced this pull request Oct 8, 2026
@lhotari hechengbo
[fix][broker] Check the original principal of proxied HTTP requests w…
e8863ae
…ith its own authentication data (apache#26748)
@lhotari lhotari added cherry-picked/branch-4.0 cherry-picked/branch-4.2 labels Oct 13, 2026
@merlimat merlimat mentioned this pull request Oct 24, 2026
[Bug] Multi-role authorization does not work properly on granting topic level permissions based on ordering of roles in token #22343
Closed
2 of 3 tasks
@nodece nodece mentioned this pull request Nov 5, 2026
[fix][ml][broker][client] Sync branch-as-4.0 with apache branch-4.0 (2026-09 to 2026-11, 159 commits) ascentstream/pulsar#109
Merged
4 of 5 tasks
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Nov 16, 2026
@lhotari @nodece
[fix][broker] Check the original principal of proxied HTTP requests w…
5670c7a
…ith its own authentication data (apache#26748)

(cherry picked from commit f0c9094)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@merlimat merlimat merlimat approved these changes
@nodece nodece Awaiting requested review from nodece
@dao-jun dao-jun Awaiting requested review from dao-jun
@Technoboy- Technoboy- Awaiting requested review from Technoboy-
@david-streamlio david-streamlio Awaiting requested review from david-streamlio

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cherry-picked/branch-4.0 cherry-picked/branch-4.2 release/4.0.14 release/4.2.5

Projects

None yet

Milestone

5.0.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@lhotari @merlimat
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.