Skip to content

Add support for custom OAuth functions #1925

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

Merged
merged 2 commits into from
Mar 14, 2025
Merged

Conversation

Claimundefine
Copy link
Contributor

@Claimundefine Claimundefine commented Feb 26, 2025

What

Add custom OAuth implementation. Created new base class for bearer field provider, which will be called to retrieve all fields that need to be modified in the header.

Checklist

  • Contains customer facing changes? Including API/behavior changes
  • Did you add sufficient unit test and/or integration test coverage for this PR?
    • If not, please explain why it is not required

References

JIRA:

https://confluentinc.atlassian.net/browse/DGS-17473

Test & Review

Tested locally with OAuth for custom.

Open questions / Follow-ups

@confluent-cla-assistant
Copy link

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

@Claimundefine Claimundefine marked this pull request as ready for review February 26, 2025 22:42
@Copilot Copilot AI review requested due to automatic review settings February 26, 2025 22:42
@Claimundefine Claimundefine requested review from a team as code owners February 26, 2025 22:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR adds support for custom OAuth functionality by introducing a common _BearerFieldProvider interface with implementations for OAuth, static tokens, and custom logic. It also updates existing tests and configuration handling to work with the new provider abstraction while removing legacy OAuth client tests.

Reviewed Changes

File Description
tests/schema_registry/test_bearer_field_provider.py Adds tests covering expiration, token retrieval, static and custom OAuth implementations.
tests/schema_registry/test_config.py Adds tests to validate custom bearer configuration handling.
src/confluent_kafka/schema_registry/schema_registry_client.py Refactors bearer auth handling by introducing _BearerFieldProvider and related classes, and adapts configuration accordingly.
tests/schema_registry/test_oauth_client.py Removes legacy OAuth client tests in favor of the new provider approach.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

tests/schema_registry/test_bearer_field_provider.py:95

  • [nitpick] The test for the custom OAuth client only asserts that get_bearer_fields() returns the same value on successive calls. Consider asserting specific expected fields from the custom function to improve test coverage.
def test_custom_oauth_client():

src/confluent_kafka/schema_registry/schema_registry_client.py:84

  • [nitpick] Consider renaming '_OAuthClient' to 'OAuthBearerFieldProvider' to better reflect its role as an implementation of _BearerFieldProvider for OAuth logic.
class _OAuthClient(_BearerFieldProvider):

@sonarqube-confluent

This comment has been minimized.

@Elmerboul
Copy link

Hi, a potential user of this functionality here 😁 Do you already have a (rough) estimate on when you plan to release this?

Copy link
Member

@rayokota rayokota left a comment

Choose a reason for hiding this comment

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

Thanks @Claimundefine , left some nits, otherwise looking good

@Claimundefine
Copy link
Contributor Author

Hi, a potential user of this functionality here 😁 Do you already have a (rough) estimate on when you plan to release this?

HI @Elmerboul, the projected release date is end of March.

@sonarqube-confluent

This comment has been minimized.

3 similar comments
@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent

This comment has been minimized.

@sonarqube-confluent
Copy link

Passed

Analysis Details

6 Issues

  • Bug 0 Bugs
  • Vulnerability 1 Vulnerability
  • Code Smell 5 Code Smells

Coverage and Duplications

  • Coverage 84.10% Coverage (62.10% Estimated after merge)
  • Duplications No duplication information (0.90% Estimated after merge)

Project ID: confluent-kafka-python

View in SonarQube

Copy link
Member

@rayokota rayokota left a comment

Choose a reason for hiding this comment

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

Thanks @Claimundefine , LGTM

@Claimundefine Claimundefine merged commit b585f24 into master Mar 14, 2025
2 checks passed
@Claimundefine Claimundefine deleted the sr_custom_oauth branch March 14, 2025 19:25
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.

3 participants