Skip to content

Conversation

@emelialei88
Copy link
Contributor

@emelialei88 emelialei88 commented Dec 8, 2025

Summary

This PR adds support for authentication credential callbacks in the BlazingMQ Python SDK, enabling applications to provide dynamic authentication credentials when connecting to secured brokers.

New API Components

  • BasicAuthnCredentialCb - Python wrapper class that accepts a callable returning (mechanism: str, data: bytes) or None
  • FakeAuthnCredentialCb - Cython class that bridges Python callbacks to C++ authentication infrastructure
  • authn_credential_cb parameter added to Session.__init__() and Session.with_options()

Implementation Details

  • Integrated C++ authentication callback infrastructure with Python callable interface
  • Implemented proper GIL management for cross-language callback invocation
  • Added support for passing authentication credentials from Python to C++ BlazingMQ SDK
  • Exposed get_credential_data() method for C++ to invoke Python callbacks

Example Usage

import blazingmq

def main() -> None:
    session = blazingmq.Session(
        blazingmq.session_events.log_session_event,
        authn_credential_cb=blazingmq.BasicAuthnCredentialCb(
            lambda: ("BASIC", b"python:sdk")
        )
    ...

Note

This is tested based on SDK authentication PR. Two places in the code change (marked as #TODO) relies on updates to SessionOptions.

@emelialei88 emelialei88 force-pushed the authn/sdk branch 2 times, most recently from c64c673 to 0663a77 Compare December 12, 2025 16:24
@emelialei88 emelialei88 changed the title provide a way to create credential Add authentication credential callback support Dec 12, 2025
@emelialei88 emelialei88 marked this pull request as ready for review December 12, 2025 16:45
@emelialei88 emelialei88 requested a review from a team as a code owner December 12, 2025 16:45
@pniedzielski pniedzielski self-requested a review December 12, 2025 17:28
@pniedzielski pniedzielski self-assigned this Dec 12, 2025
Signed-off-by: Emelia Lei <wlei29@bloomberg.net>
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.

2 participants