You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "codelipenghui (via GitHub)" <gi...@apache.org> on 2025/07/18 06:27:28 UTC

[PR] [fix][websocket] Fix WebSocket dummy principal authorization issue [pulsar]

codelipenghui opened a new pull request, #24533:
URL: https://github.com/apache/pulsar/pull/24533

   ## Summary
   This PR fixes an authorization issue where WebSocket connections through Pulsar proxy would fail when both authentication and authorization were enabled.
   
   ## Changes
   - Added `WEBSOCKET_DUMMY_ORIGINAL_PRINCIPLE` constant for WebSocket connections
   - Modified `AuthorizationService` to handle WebSocket dummy principal cases  
   - Updated `WebSocketService` to set dummy original principal for internal client
   - Added `originalPrincipal` method to `ClientBuilderImpl`
   - Updated authorization checks across multiple broker components
   - Added comprehensive integration test `WebSocketProxyAuthIntegrationTest`
   
   ## Problem
   When WebSocket connections were made through a Pulsar proxy with both authentication and authorization enabled, the authorization logic would fail because:
   
   1. The system detected the client role as a proxy role (e.g., "websocket_proxy")
   2. For proxy roles, the system requires both the proxy role AND the original client role to be authorized
   3. WebSocket connections didn't have a proper original principal set, causing authorization to fail
   
   ## Solution
   Introduced a "dummy original principal" concept specifically for WebSocket connections:
   
   - WebSocket service sets a dummy original principal when creating its internal client
   - Authorization service detects this dummy principal and skips dual authorization
   - Only applies single authorization (just the proxy role) for WebSocket connections
   - Maintains security by still authorizing the proxy role itself
   
   ## Key Changes
   
   ### Core Authorization Logic (`AuthorizationService.java`)
   ```java
   if (isProxyRole(authParams.getClientRole()) && \!isWebsocketPrinciple(authParams.getOriginalPrincipal())) {
       // Apply dual authorization (proxy + original principal)
   } else {
       // Apply single authorization (just the client role)
   }
   ```
   
   ### WebSocket Service (`WebSocketService.java`)
   ```java
   if (clientBuilder instanceof ClientBuilderImpl) {
       ((ClientBuilderImpl) clientBuilder).originalPrincipal(WEBSOCKET_DUMMY_ORIGINAL_PRINCIPLE);
   }
   ```
   
   ## Test Plan
   - Added `WebSocketProxyAuthIntegrationTest` with JWT token authentication
   - Tests WebSocket proxy with authentication and authorization enabled
   - Validates produce/consume operations work correctly with different tokens:
     - `ADMIN_TOKEN`: Used by admin client for setup operations
     - `PROXY_TOKEN`: Used by WebSocket proxy's internal client
     - `CLIENT_TOKEN`: Used by WebSocket clients
   - Ensures proper authorization flow with dummy principal handling
   
   ## Verification
   The integration test confirms:
   - WebSocket connections can authenticate through proxy with proper tokens
   - Authorization works correctly with the dummy principal approach
   - Messages can be successfully produced and consumed
   - No regression in existing proxy authorization behavior
   
   🤖 Generated with [Claude Code](https://claude.ai/code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][ws] Fix WebSocket authorization issue due to originalPrincipal must be provided [pulsar]

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on PR #24533:
URL: https://github.com/apache/pulsar/pull/24533#issuecomment-3089749400

   /pulsarbot run-failure-checks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][websocket] Fix WebSocket authorization issue due to originalPrincipal must be provided [pulsar]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #24533:
URL: https://github.com/apache/pulsar/pull/24533#issuecomment-3087280672

   @codelipenghui Please add the following content to your PR description and select a checkbox:
   ```
   - [ ] `doc` <!-- Your PR contains doc changes -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][ws] Fix WebSocket authorization issue due to originalPrincipal must be provided [pulsar]

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on PR #24533:
URL: https://github.com/apache/pulsar/pull/24533#issuecomment-3087671392

   /pulsarbot run-failure-checks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][ws] Fix WebSocket authorization issue due to originalPrincipal must be provided [pulsar]

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on PR #24533:
URL: https://github.com/apache/pulsar/pull/24533#issuecomment-3090132962

   /pulsarbot run-failure-checks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][websocket] Fix WebSocket dummy principal authorization issue [pulsar]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #24533:
URL: https://github.com/apache/pulsar/pull/24533#issuecomment-3087222443

   @codelipenghui Please add the following content to your PR description and select a checkbox:
   ```
   - [ ] `doc` <!-- Your PR contains doc changes -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][ws] Fix WebSocket authorization issue due to originalPrincipal must be provided [pulsar]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24533:
URL: https://github.com/apache/pulsar/pull/24533#issuecomment-3099374800

   ## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/24533?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: Patch coverage is `44.73684%` with `21 lines` in your changes missing coverage. Please review.
   > Project coverage is 74.27%. Comparing base [(`bbc6224`)](https://app.codecov.io/gh/apache/pulsar/commit/bbc62245c5ddba1de4b1e7cee4ab49334bc36277?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`dd146d2`)](https://app.codecov.io/gh/apache/pulsar/commit/dd146d2561feedc8dbdef23bc8564b7940110fb6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 1208 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/pulsar/pull/24533?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...sar/broker/authorization/AuthorizationService.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-broker-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fauthorization%2FAuthorizationService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9icm9rZXIvYXV0aG9yaXphdGlvbi9BdXRob3JpemF0aW9uU2VydmljZS5qYXZh) | 15.38% | [0 Missing and 11 partials :warning: ](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...authentication/AuthenticationDataSubscription.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-broker-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fauthentication%2FAuthenticationDataSubscription.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9icm9rZXIvYXV0aGVudGljYXRpb24vQXV0aGVudGljYXRpb25EYXRhU3Vic2NyaXB0aW9uLmphdmE=) | 20.00% | [3 Missing and 5 partials :warning: ](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...pulsar/broker/admin/impl/PersistentTopicsBase.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fadmin%2Fimpl%2FPersistentTopicsBase.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL1BlcnNpc3RlbnRUb3BpY3NCYXNlLmphdmE=) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [.../org/apache/pulsar/websocket/WebSocketService.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-websocket%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fwebsocket%2FWebSocketService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLXdlYnNvY2tldC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL3dlYnNvY2tldC9XZWJTb2NrZXRTZXJ2aWNlLmphdmE=) | 50.00% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/pulsar/pull/24533/graphs/tree.svg?width=650&height=150&src=pr&token=acYqCpsK9J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #24533      +/-   ##
   ============================================
   + Coverage     73.57%   74.27%   +0.70%     
   + Complexity    32624    32549      -75     
   ============================================
     Files          1877     1869       -8     
     Lines        139502   146095    +6593     
     Branches      15299    16759    +1460     
   ============================================
   + Hits         102638   108518    +5880     
   - Misses        28908    28958      +50     
   - Partials       7956     8619     +663     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pulsar/pull/24533/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [inttests](https://app.codecov.io/gh/apache/pulsar/pull/24533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `26.71% <18.42%> (+2.12%)` | :arrow_up: |
   | [systests](https://app.codecov.io/gh/apache/pulsar/pull/24533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `23.29% <10.52%> (-1.04%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pulsar/pull/24533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.78% <44.73%> (+0.94%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/pulsar/pull/24533?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...g/apache/pulsar/broker/lookup/TopicLookupBase.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Flookup%2FTopicLookupBase.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9sb29rdXAvVG9waWNMb29rdXBCYXNlLmphdmE=) | `68.42% <100.00%> (+1.00%)` | :arrow_up: |
   | [...va/org/apache/pulsar/broker/service/ServerCnx.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fservice%2FServerCnx.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL1NlcnZlckNueC5qYXZh) | `72.34% <100.00%> (+0.20%)` | :arrow_up: |
   | [...rg/apache/pulsar/broker/web/PulsarWebResource.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fweb%2FPulsarWebResource.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci93ZWIvUHVsc2FyV2ViUmVzb3VyY2UuamF2YQ==) | `65.21% <100.00%> (+1.17%)` | :arrow_up: |
   | [...g/apache/pulsar/client/impl/ClientBuilderImpl.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fclient%2Fimpl%2FClientBuilderImpl.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NsaWVudEJ1aWxkZXJJbXBsLmphdmE=) | `85.79% <100.00%> (-0.20%)` | :arrow_down: |
   | [.../java/org/apache/pulsar/client/impl/ClientCnx.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fclient%2Fimpl%2FClientCnx.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NsaWVudENueC5qYXZh) | `69.37% <100.00%> (-2.41%)` | :arrow_down: |
   | [...lsar/client/impl/conf/ClientConfigurationData.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fclient%2Fimpl%2Fconf%2FClientConfigurationData.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL2NvbmYvQ2xpZW50Q29uZmlndXJhdGlvbkRhdGEuamF2YQ==) | `93.33% <ø> (-3.37%)` | :arrow_down: |
   | [...pulsar/broker/admin/impl/PersistentTopicsBase.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fadmin%2Fimpl%2FPersistentTopicsBase.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL1BlcnNpc3RlbnRUb3BpY3NCYXNlLmphdmE=) | `69.99% <0.00%> (+4.54%)` | :arrow_up: |
   | [.../org/apache/pulsar/websocket/WebSocketService.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-websocket%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fwebsocket%2FWebSocketService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLXdlYnNvY2tldC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL3dlYnNvY2tldC9XZWJTb2NrZXRTZXJ2aWNlLmphdmE=) | `79.71% <50.00%> (-1.54%)` | :arrow_down: |
   | [...authentication/AuthenticationDataSubscription.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-broker-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fauthentication%2FAuthenticationDataSubscription.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9icm9rZXIvYXV0aGVudGljYXRpb24vQXV0aGVudGljYXRpb25EYXRhU3Vic2NyaXB0aW9uLmphdmE=) | `50.00% <20.00%> (-14.29%)` | :arrow_down: |
   | [...sar/broker/authorization/AuthorizationService.java](https://app.codecov.io/gh/apache/pulsar/pull/24533?src=pr&el=tree&filepath=pulsar-broker-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fauthorization%2FAuthorizationService.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9icm9rZXIvYXV0aG9yaXphdGlvbi9BdXRob3JpemF0aW9uU2VydmljZS5qYXZh) | `53.71% <15.38%> (-4.50%)` | :arrow_down: |
   
   ... and [1094 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/24533/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][ws] Fix WebSocket authorization issue due to originalPrincipal must be provided [pulsar]

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on PR #24533:
URL: https://github.com/apache/pulsar/pull/24533#issuecomment-3090738226

   /pulsarbot run-failure-checks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][ws] Fix WebSocket authorization issue due to originalPrincipal must be provided [pulsar]

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on PR #24533:
URL: https://github.com/apache/pulsar/pull/24533#issuecomment-3089705812

   > I haven't checked the details yet, but I'm just wondering why couldn't the WebSocket service set the original principal to the actual value of the authenticated principal instead of using a "dummy value" so that WebSocket wouldn't be an exception in how authorization works via the proxy. The downside of this dummy value solution is that WebSocket connections would all have the authorizations of the proxy role which is usually a super user.
   
   @lhotari
   
   Thank you for the excellent question! Let me explain the two major technical reasons why WebSocket proxy cannot use the same authorization approach as the regular Pulsar proxy:
   
   1. Avoiding Duplicated Authorization
   
   The WebSocket proxy is already performing authorization when clients connect and attempt operations. Requiring the broker to re-authorize the same client would be Redundant and Inefficient.
   
   https://github.com/apache/pulsar/blob/702c73cb5e0a8aea45e4367b3a974366971ca822/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/AbstractWebSocketHandler.java#L124-L150
   
   2. Shared Pulsar Client Architecture
   
   This is the crucial technical constraint. WebSocket proxy uses a single shared Pulsar client for all WebSocket connections.
   
   https://github.com/apache/pulsar/blob/702c73cb5e0a8aea45e4367b3a974366971ca822/pulsar-websocket/src/main/java/org/apache/pulsar/websocket/WebSocketService.java#L186-L223
   
   I will also these context to the PR description.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][ws] Fix WebSocket authorization issue due to originalPrincipal must be provided [pulsar]

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui merged PR #24533:
URL: https://github.com/apache/pulsar/pull/24533


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org