-
Notifications
You must be signed in to change notification settings - Fork 131
feat: Support SCRAM and OAuth mechanisms in Kafka plugin #479
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
base: main
Are you sure you want to change the base?
Conversation
f86faaf to
6f9576f
Compare
6f9576f to
9e1524b
Compare
9e1524b to
e64fdc9
Compare
e64fdc9 to
07c66f9
Compare
44d8317 to
6a44eb2
Compare
d865131 to
644010d
Compare
a701145 to
ba437d9
Compare
Added support for fetching tokens from external Auth Servers. When fetching tokens supports * client_secret_basic * client_secret_post * client_secret_jwt * private_key_jwt These authentication methods are described in RFC 6749 and RFC 7523 Added validations for SCRAM-SHA-256 and SCRAM-SHA-512 With this PR we have complete support for all SASL Mechanisms needed in Kafka * PLAIN * SCRAM-SHA-256 * SCRAM-SHA-512 * GSSAPI * OAUTHBEARER
bbd7d4d to
b8c025d
Compare
for more information, see https://pre-commit.ci
| files: ^.config\/.*requirements.*$ | ||
| language: python | ||
| language_version: "3.9" # minimal we support officially | ||
| language_version: "3.10" # minimal we support officially |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's do this in a different PR and set 3.11 as minimal.
| description: | ||
| - The kerberos REALM | ||
| type: str | ||
| sasl_oauth_token_endpoint: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would have already 17 sasl related parameters, this is a awful and bad interface IMO. We should nest all these params into their own sasl config object, with backward compatibility of the existing params with deprecation in favor of the new system. Which probably should be correlated with an internal schema for sasl config because dealing with some many fields with a regular dict becomes hard to read and maintain.
| if offset not in ("latest", "earliest"): | ||
| msg = f"Invalid offset option: {offset}" | ||
| raise ValueError(msg) | ||
| _validate_args(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaults management is inconsistent because we already set the default values also in main, the default values should be set only in one place.
Encapsulating validation is great but it should be called before declaring any other variable that comes from the args.
I suggest a validate args object, where we can centralize parsing, validation and defaults.
| if sasl_oauth_method not in OAUTH_CLASSES_MAP: | ||
| msg = ( | ||
| f"OAUTHBEARER invalid sasl_oauth_method: {sasl_oauth_method}. " | ||
| f"Should be one of : {','.join(OAUTH_CLASSES_MAP)}" | ||
| ) | ||
| raise ValueError(msg) | ||
|
|
||
| if sasl_oauth_method in PRIVATE_KEY_METHODS and not args.get( | ||
| "sasl_oauth_private_keyfile" | ||
| ): | ||
| msg = ( | ||
| f"When using {sasl_oauth_method} a private key file is needed. " | ||
| "Please provide sasl_oauth_private_keyfile" | ||
| ) | ||
| raise ValueError(msg) | ||
|
|
||
| if sasl_oauth_method in CLIENT_SECRET_METHODS and not args.get( | ||
| "sasl_oauth_client_secret" | ||
| ): | ||
| msg = ( | ||
| f"When using {sasl_oauth_method} a client secret is needed. " | ||
| "Please provide sasl_oauth_client_secret" | ||
| ) | ||
| raise ValueError(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like something that should be also encapsulated at the validation
|
|
||
| except aiohttp.ClientError as e: | ||
| LOGGER.error("Failed to obtain OAuth2 token: %s", str(e)) | ||
| LOGGER.error("Response text %s", str(response_text)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure response_text will not contain sensitive data?
| ) | ||
| raise ValueError(msg) | ||
|
|
||
| if sasl_mechanism in USER_PASSWORD_MECHANISMS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
USER_PASSWORD_MECHANISMS does not include PLAIN
Added support for fetching tokens from external Auth Servers. When fetching tokens supports
These authentication methods are described in RFC 6749 and RFC 7523
Added validations for SCRAM-SHA-256 and SCRAM-SHA-512
With this PR we have complete support for all SASL Mechanisms needed in Kafka