Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Added Kafka OIDC + azure.identity independent producer/consumer examples. #227

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Pilipets
Copy link

@Pilipets Pilipets commented Dec 10, 2022

There were no examples for Kafka OIDC and accessing the Azure event hub without the azure identity library.

This pull request introduces new examples of producer/consumer to address the above issues:

  1. OIDC SASL_SSL - get_oidc_config
  2. SASL_SSL with custom token refresh callback without azure.identity dependency - get_cb_config

The current PR is a draft one - let me know if you find it useful.
Then I will create README.md, will write code in more OOP-like manner and add more comments for the used concepts.

More context one can gather from the issue I created recently.
Examples are based on the existing code in tutorials for Python-oauth.

CC @hmlam

@Pilipets
Copy link
Author

@microsoft-github-policy-service agree

@microsoft-github-policy-service agree

@Pilipets Pilipets changed the title Enhancement: Added more Python Kafka oauth examples - producer + consumer: Enhancement: Added Kafka OIDC + azure.identity independent producer/consumer examples. Dec 10, 2022
Copy link
Member

@hmlam hmlam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some house-keeping comments

  • since it is OIDC sample, we can probably use the folder "oidc" (or OpenIdConnect) as oppose to more_example.
  • sample will need to have the default comment header for licenses etc. example can be taken from other samples.

@Pilipets Pilipets force-pushed the hpylypets_oauth_examples branch from 6078782 to 1d9a2d8 Compare June 5, 2023 02:24
Pilipets added 2 commits June 4, 2023 22:27
- Added an option to run producer, consumer with --mode=[oidc, azure, opaque]
- oidc corresponds to KIP-768 and decoding JWT with the usage of exp claim
- opaque utilizes expires_in field without azure.identity dependency

Signed-off-by: Hlib Pylypets <[email protected]>
@Pilipets
Copy link
Author

Pilipets commented Jun 5, 2023

@hmlam, sorry for the delay in response.

I didn't want to duplicate the same producer/consumer logic for oidc, opaque folders, so decided to modify the structure of producer/consumer and extend the usage functionality.

  1. Added license headers as you requested.
  2. Added config_utils.py that provides producer configs for three modes - azure, oidc, opaque.
  3. Extended producer, consumer functionality to be able to run those with --mode which is one of above mentioned modes.
  4. No need to change README.md because both Python scripts can be used as before. Therefore, backward compatibility is maintained, and newly added functionality is optional.
  5. Tested all the changes manually.
  6. I preserved all the comments and added new ones for oidc, opaque modes:
    • oidc corresponds to KIP-768 and decoding JWT with the usage of exp claim
    • opaque utilizes expires_in field and network requests without azure.identity dependency

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