Skip to content

Conversation

@emelialei88
Copy link
Collaborator

@emelialei88 emelialei88 commented Oct 24, 2025

This PR introduces several refactors and preparations for upcoming authentication support:

  • Adds an Authenticator class to encapsulate authentication logic.
  • Migrates connection initialization logic from InitialConnectionHandler to InitialConnectionContext. Note that InitialConnectionHandler will be deprecated and removed in a future update.

At this stage, TcpSessionFactory still relies on InitialConnectionHandler for negotiation, while InitialConnectionContext primarily serves as a data holder. Authentication logic has not yet been integrated into the broker. When we are ready, InitialConnectionHandler::handleInitialConnection called in TcpSessionFactory will be replaced by InitialConnectionContext::handleInitialConnection as the entrance to initial connection.

@emelialei88 emelialei88 requested a review from a team as a code owner October 24, 2025 19:53
@emelialei88 emelialei88 marked this pull request as draft October 24, 2025 20:58
@678098 678098 self-assigned this Nov 6, 2025
@678098 678098 self-requested a review November 6, 2025 16:05
@emelialei88 emelialei88 force-pushed the authn/change-negotiator branch from 0816869 to 788d0eb Compare November 11, 2025 18:22
@emelialei88 emelialei88 force-pushed the authn/change-negotiator branch from d2c4c40 to ea2450d Compare November 12, 2025 18:51
Signed-off-by: Emelia Lei <[email protected]>
@emelialei88 emelialei88 marked this pull request as ready for review November 12, 2025 19:38
Signed-off-by: Emelia Lei <[email protected]>
Copy link
Collaborator

@dorjesinpo dorjesinpo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interim review.
we have pairs of the following:
decodeInitialConnectionMessage,
scheduleRead,
readCallback
readBlob,
processBlob,
complete
... in both InitialConnectionHandler and InitialConnectionContext.

The point of FSM-like state management is that everything happens in handleEvent and there is only one place where we call complete
Otherwise, we can't rely on controlling actions by the state

Is it possible to engage handleEvent immediately in InitialConnectionHandler::handleInitialConnection and call InitialConnectionContext::complete from handleEvent only.

We seem to have InitialConnectionContext::handleInitialConnection but we call InitialConnectionHandler::handleInitialConnection instead which does not seem to support auth?

this,
initialConnectionContext,
context_wp,
channel,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment below is unclear. What mutex is meant by "we can't have mutex?

}

if (rc != rc_SUCCESS || d_state == InitialConnectionState::e_NEGOTIATED) {
BALL_LOG_INFO << "Finished initial connection with rc = " << rc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if rc != rc_SUCCESS then d_state can remain InitialConnectionState::e_NEGOTIATED. Probably, not a problem since the object is about to get destructed

context));

// Register as observer of the channel to get the 'onClose'
bsl::weak_ptr<InitialConnectionContext> context_wp =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the motivation behind the use of weak_ptr?


// For anonymous authentication, skip sending the response and proceed
// directly to the next negotiation step.
if (isDefaultAuthn) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, if isReauthn, there is no need for authenticationResponse

bslmt::LockGuard<bslmt::Mutex> guard(&d_mutex); // LOCKED

if (d_state != AuthenticationState::e_AUTHENTICATING) {
errorDescription << "State not AUTHENTICATING (was " << d_state << ")";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was -> is

@dorjesinpo dorjesinpo assigned emelialei88 and unassigned dorjesinpo Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants