Skip to content

Add authentication credential callback support#61

Open
emelialei88 wants to merge 15 commits into
bloomberg:mainfrom
emelialei88:authn/sdk
Open

Add authentication credential callback support#61
emelialei88 wants to merge 15 commits into
bloomberg:mainfrom
emelialei88:authn/sdk

Conversation

@emelialei88

@emelialei88 emelialei88 commented Dec 8, 2025

Copy link
Copy Markdown
Collaborator

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=lambda: ("BASIC", b"python:sdk")
    ...

@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
@pniedzielski pniedzielski force-pushed the authn/sdk branch 2 times, most recently from a8ae7c5 to b1aeca1 Compare June 22, 2026 19:50
Signed-off-by: Emelia Lei <wlei29@bloomberg.net>
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
`LOGGER.exception` already captures and prints the currently in-flight
exception.  This patch removes the unused variable binding on the
exception.

Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
We check this error in different layers, along with providing type
annotations for use with something like mypy.  The closest parallel
example we have is `FakeHostHealthMonitor`, which only does runtime
type checking at the highest layer, in pure Python.  This patch
removes the duplicate error checking from the Cython layer.

Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
This type doesn’t do much of anything on its own, and only makes it
harder for a user to provide their own authentication credential
provider, by forcing them to wrap whatever function they have in this
type.  This patch removes the class and lets users just pass any
`Callable` of the right signature when constructing a `Session`.

Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Right now, this defaults to `None` (i.e, no authentication).

Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Signed-off-by: Patrick M. Niedzielski <pniedzielski@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