Repository navigation
Add authentication credential callback support - #61
Merged
Merged
Conversation
emelialei88
force-pushed
the
authn/sdk
branch
2 times, most recently
from
December 12, 2025 16:24
c64c673 to
0663a77
Compare
emelialei88
force-pushed
the
authn/sdk
branch
from
December 12, 2025 16:35
0663a77 to
70c3f88
Compare
emelialei88
marked this pull request as ready for review
December 12, 2025 16:45
pniedzielski
self-requested a review
December 12, 2025 17:28
emelialei88
force-pushed
the
authn/sdk
branch
from
December 12, 2025 17:48
70c3f88 to
1c01ff0
Compare
pniedzielski
force-pushed
the
authn/sdk
branch
4 times, most recently
from
June 26, 2026 19:56
589d4f1 to
02041f7
Compare
pniedzielski
force-pushed
the
authn/sdk
branch
3 times, most recently
from
July 1, 2026 21:27
070d6be to
dc5e839
Compare
pniedzielski
force-pushed
the
authn/sdk
branch
2 times, most recently
from
September 4, 2026 19:00
2da9d8d to
55ce501
Compare
pniedzielski
force-pushed
the
authn/sdk
branch
5 times, most recently
from
September 4, 2026 20:16
0f267de to
909a8d4
Compare
pniedzielski
force-pushed
the
authn/sdk
branch
from
September 18, 2026 21:14
909a8d4 to
9573080
Compare
arnaudmorin
pushed a commit
to arnaudmorin/blazingmq-sdk-python
that referenced
this pull request
Oct 22, 2026
- Build against arnaudmorin/blazingmq@ee5a2b7c, which initializes the TLS flag of the connect options: it was random, and plain connections aborted on an assertion when they were seen as TLS. - The authentication tests of bloomberg#61 did not expect the user_agent_prefix argument and failed. Signed-off-by: Arnaud M. <arnaud.choupinette@mailops.fr> Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
pniedzielski
force-pushed
the
authn/sdk
branch
from
October 26, 2026 14:39
9573080 to
71e1512
Compare
Closed
pniedzielski
force-pushed
the
authn/sdk
branch
from
October 26, 2026 15:08
66a1e60 to
ecb21b4
Compare
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
pniedzielski
force-pushed
the
authn/sdk
branch
2 times, most recently
from
October 26, 2026 15:57
4817ddf to
03fbbcb
Compare
678098
previously approved these changes
Oct 26, 2026
678098
left a comment
Contributor
There was a problem hiding this comment.
Looks good, just a few comments
| result = adapter.get_credential_data() | ||
|
|
||
| # THEN | ||
| assert result == (b"PLAIN\x00extra", b"data") |
Contributor
There was a problem hiding this comment.
We might log mechanism on the broker.
Not sure if we want to allow every possible character there
https://github.com/bloomberg/blazingmq/pull/1776/changes
Contributor
There was a problem hiding this comment.
This is a good point. I have three thoughts:
- C++ and Java SDKs don't seem to do any validation on this front. We probably should. If the C++ SDK did validation we would get it here "for free" (though we may still want to do it in pure Python to get a nicer error message). Whatever we do, we should probably do it everywhere.
- Here, I think this test is probably still worthwhile, because it checks a Cython type conversion, which can silently drop anything after the NUL byte. Unless we validate and reject in pure Python that's still going to be a possibility.
- Broker should also validate, I think, from the wire, from the config, and from the plugin.
I'm not sure exactly what the limits should be, though. Maybe it's okay for now to encode the string on the broker just before logging it? What are your thoughts on this?
Contributor
There was a problem hiding this comment.
What do you mean by "encode" in this context? Sanitize the string by replacing non-readable characters with ? as we do now?
We can perform the check in SDK then.
This patch adds an optional `authn_credential_provider` argument to `Session` and `SessionOptions`. It is a callable returning a `(mechanism, data)` tuple of `(str, bytes)`, called each time the session authenticates with the broker, including on reauthentication. If it returns `None` or raises, the connection is closed: starting a session fails, while an already-started session sees `ConnectionLost` and then reconnects, calling the provider again. If no provider is given, no credentials are sent, as before. The provider is then wrapped in a Cython `AuthnCredentialCbAdapter` as a translation layer between the pure Python callable and the C++ `bmqt::SessionOptions::AuthnCredentialCb`. From there, the C++ SDK takes over all authentication work. Signed-off-by: Emelia Lei <wlei29@bloomberg.net> Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
pniedzielski
force-pushed
the
authn/sdk
branch
from
October 29, 2026 15:57
03fbbcb to
5802623
Compare
678098
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 NoneFakeAuthnCredentialCb- Cython class that bridges Python callbacks to C++ authentication infrastructureauthn_credential_cbparameter added toSession.__init__()andSession.with_options()Implementation Details
get_credential_data()method for C++ to invoke Python callbacksExample Usage