-
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
base: master
Are you sure you want to change the base?
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
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>
|
/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>
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