Support setting principal and SASL extensions in oauth_cb, handle failures #1402
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.
Fixes #1394
Extends the return values of the
oauth_cb
to include a principal string, and a dict of SASL extensions, which must be strings matching[A-Za-z]+
. These return values are optional, meaning that existing callbacks still work.When an exception is raised in the callback,
rd_kafka_oauthbearer_set_token_failure
is called to ensure another refresh is scheduled 10s later. This is for the case where the callback raising an exception is due to a token not being able to be fetched, which may succeed later. Without this, raising exceptions in the callback result in the client never re-fetching a token unless fully restarted.Suggestions regarding the latter part are appreciated, an alternative would be to allow a return value of
None
to signal token fetch failure and the need to retry later. However raising an exception is a bit more Pythonic, so maybe raising a certain exception type should be the way to signal a failure.