Skip to content

Conversation

emelialei88
Copy link
Collaborator

@emelialei88 emelialei88 commented Jul 29, 2025

Summary

This PR introduces optional client authentication (and scheduled re‑authentication) into the BlazingMQ SDK by inserting an AuthenticatedChannelFactory layer between the existing stat and negotiated channel factories. When a TCP channel reaches e_CHANNEL_UP, the factory performs an authentication exchange before exposing the channel to higher layers. If the broker’s response provides a lifetime, a re‑authentication timer is scheduled; it is cancelled automatically on channel loss and re-established after reconnect.

Key Points

  • Added AuthenticatedChannelFactory to run an auth handshake transparently after connection.
  • Introduced support for a user-supplied credential callback SessionOptions::setAuthnCredentialCb.
    • If not provided, behavior is unchanged (fully backward compatible).
  • Authentication requests are treated as non-buffered (never replayed across disconnects).
  • Re-authentication is scheduled based on the lifetime returned in the broker's response and safely cancelled on channel down.

Example

auto authnFunc = [](bsl::ostream&) -> bsl::optional<bmqt::AuthnCredential> {
    bsl::string data = "user1:password1";
    bsl::string mechanism = "Basic";
    bmqt::AuthnCredential cred(mechanism, bsl::vector<char>(data.begin(), data.end()));
    return cred;
};
sessionOptions.setAuthnCredentialCb(authnFunc);

@emelialei88 emelialei88 requested a review from a team as a code owner July 29, 2025 15:51
@emelialei88 emelialei88 marked this pull request as draft July 29, 2025 15:51
@emelialei88 emelialei88 force-pushed the integration/authn-authz branch from b485062 to 11e680d Compare July 30, 2025 16:06
@emelialei88 emelialei88 force-pushed the integration/authn-authz branch from eff6740 to a371191 Compare July 30, 2025 16:20
@emelialei88 emelialei88 force-pushed the feat/authn-sdk branch 2 times, most recently from 96e094a to ebc8cbd Compare July 31, 2025 19:29
@emelialei88 emelialei88 force-pushed the integration/authn-authz branch 2 times, most recently from 744c51f to 55ae385 Compare August 15, 2025 19:25
@emelialei88 emelialei88 force-pushed the integration/authn-authz branch from 55ae385 to a69c9ed Compare August 22, 2025 15:50
@emelialei88 emelialei88 force-pushed the feat/authn-sdk branch 2 times, most recently from 71de0e5 to ba96877 Compare August 28, 2025 20:01
@emelialei88 emelialei88 force-pushed the integration/authn-authz branch from a69c9ed to dfc0672 Compare August 29, 2025 21:34
@emelialei88 emelialei88 force-pushed the feat/authn-sdk branch 2 times, most recently from fe3f1cc to fa20273 Compare September 2, 2025 15:27
@emelialei88 emelialei88 force-pushed the integration/authn-authz branch from dfc0672 to 7eb72db Compare September 8, 2025 15:37
@emelialei88 emelialei88 force-pushed the integration/authn-authz branch from 7eb72db to cd85bdd Compare September 11, 2025 21:08
@emelialei88 emelialei88 force-pushed the integration/authn-authz branch from cd85bdd to 3203266 Compare September 22, 2025 14:16
@emelialei88 emelialei88 force-pushed the integration/authn-authz branch from 3203266 to b3ab443 Compare September 23, 2025 20:47
Signed-off-by: Emelia Lei <[email protected]>
@emelialei88 emelialei88 force-pushed the integration/authn-authz branch from b3ab443 to 850d3d4 Compare October 3, 2025 17:26
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