This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
Add KoP's own callback handlers for OAuth 2.0 authentication #405
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.
Based on the framework from #400, this PR adds two callback handlers and their associated configs:
OauthLoginCallbackHandler
andClientConfig
: They are in an independent module and for Kafka client to get access token from a third-party OAuth 2.0 authorization server. It requires issuer URI, credential file's URI and andience, just like what Pulsar client does.OauthValidatorCallbackHandler
andServerConfig
: It validates the client's access token using Pulsar'sAuthenticationProvider
whoseauthMethod
is determined by a config ofServerConfig
.Since the validate callback handler is created by
SaslServer
, we cannot pass construct params to it. So this PR makesAuthenticationService
static so that the callback handler could access it.Also this PR exposed the role (or authorization id) for the implementation of authorization in future.
Unit tests are added for
ServerConfig
andClientConfig
and an integration test is added for OAuth 2.0 authentication with the new added callback handlers in this PR.