-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[improve][broker] Extract authentication logic from ServerCnx to dedicated class #24878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Refactors broker authentication by extracting the logic from ServerCnx into dedicated classes for modularity and reuse (e.g., proxy/original-role authentication).
- Introduces BinaryAuthSession and BinaryAuthContext to encapsulate auth flow and context
- Updates ServerCnx to delegate auth/connect/auth-response handling to BinaryAuthSession
- Adds a factory method in AuthenticationService to create BinaryAuthSession
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java | Replaces inline authentication logic with BinaryAuthSession orchestration during connect and auth responses. |
| pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/BinaryAuthSession.java | New class implementing the binary authentication flow, including proxy/original-client handling and challenges. |
| pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/BinaryAuthContext.java | New context container for auth session parameters (connect command, SSL, executor, etc.). |
| pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java | Adds a simple factory method to create BinaryAuthSession. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...r-broker-common/src/main/java/org/apache/pulsar/broker/authentication/BinaryAuthSession.java
Show resolved
Hide resolved
...r-broker-common/src/main/java/org/apache/pulsar/broker/authentication/BinaryAuthSession.java
Outdated
Show resolved
Hide resolved
...r-broker-common/src/main/java/org/apache/pulsar/broker/authentication/BinaryAuthSession.java
Show resolved
Hide resolved
...r-broker-common/src/main/java/org/apache/pulsar/broker/authentication/BinaryAuthSession.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
Outdated
Show resolved
Hide resolved
...r-broker-common/src/main/java/org/apache/pulsar/broker/authentication/BinaryAuthSession.java
Show resolved
Hide resolved
...r-broker-common/src/main/java/org/apache/pulsar/broker/authentication/BinaryAuthSession.java
Show resolved
Hide resolved
...r-broker-common/src/main/java/org/apache/pulsar/broker/authentication/BinaryAuthContext.java
Show resolved
Hide resolved
|
/pulsarbot rerun-failure-checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
Outdated
Show resolved
Hide resolved
...r-broker-common/src/main/java/org/apache/pulsar/broker/authentication/BinaryAuthSession.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
4350f7c to
4a2ce3b
Compare
|
When adding new classes like BinaryAuthSession and BinaryAuthContext, please pay attention to add class level javadocs to explain the abstraction. It should also be considered whether an interface is used for BinaryAuthContext to make it easier to keep the API backwards compatible in the future. It's currently not clear what the extension model is and how a custom implementation could help extend the authentication logic. |
|
This implementation aims to unify authentication handling between the broker and proxy. It’s not currently designed for external extension or customization. I plan to test this in our forked Pulsar. |
Motivation
The current authentication flow in broker is tightly coupled with the
ServerCnxclass, making it harder to extend authentication logic (e.g., for proxy authentication, role forwarding). This PR refactors the authentication handling into dedicated classes to make the flow more modular, extensible, and easier to maintain.Modifications
Documentation
docdoc-requireddoc-not-neededdoc-complete