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

Update registry rest client to support bearer authentication #1721

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gtato
Copy link

@gtato gtato commented Mar 9, 2024

This change allows schema registry clients to specify a token in case the registry server supports token/oidc authentication.

@gtato gtato requested a review from a team as a code owner March 9, 2024 21:29
Copy link

cla-assistant bot commented Mar 9, 2024

CLA assistant check
All committers have signed the CLA.

@iamed2
Copy link

iamed2 commented Aug 14, 2024

When using Bearer auth from curl, we needed to provide additional headers for Confluent-Identity-Pool-Id and target-sr-cluster. Have you succeeded in using this branch to connect?

Additionally, needing to recreate the client whenever a token refresh is needed is cumbersome. Inserting a user-provided token-fetching callback as part of a custom auth for the Requests Session may be a more user-friendly option. A custom auth could look something like:

class BearerAuth(requests.auth.AuthBase):
    def __init__(self, token_cb):
        self.token_cb = token_cb

    def __call__(self, request):
        """Called directly by requests to add the Authorization header"""
        token = token_cb()
        request.headers["Authorization"] = f"Bearer {token}"
        return request

and you can hook this in by setting self.session.auth = BearerAuth(token_cb).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants