Skip to content

Conversation

@mkanoor
Copy link
Contributor

@mkanoor mkanoor commented Oct 5, 2025

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

@github-actions github-actions bot added the feat New feature ore request label Oct 5, 2025
@mkanoor mkanoor force-pushed the extend_sasl_mechanisms branch from f86faaf to 6f9576f Compare October 5, 2025 16:40
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 5, 2025
@mkanoor mkanoor force-pushed the extend_sasl_mechanisms branch from 6f9576f to 9e1524b Compare October 5, 2025 21:23
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 5, 2025
@mkanoor mkanoor force-pushed the extend_sasl_mechanisms branch from 9e1524b to e64fdc9 Compare October 5, 2025 21:46
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 5, 2025
@mkanoor mkanoor force-pushed the extend_sasl_mechanisms branch from e64fdc9 to 07c66f9 Compare October 6, 2025 01:02
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 6, 2025
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 6, 2025
@mkanoor mkanoor force-pushed the extend_sasl_mechanisms branch from 44d8317 to 6a44eb2 Compare October 6, 2025 01:12
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 6, 2025
@mkanoor mkanoor force-pushed the extend_sasl_mechanisms branch from d865131 to 644010d Compare October 11, 2025 18:53
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 11, 2025
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 11, 2025
@mkanoor mkanoor force-pushed the extend_sasl_mechanisms branch from a701145 to ba437d9 Compare October 11, 2025 21:09
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 11, 2025
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 11, 2025
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
@mkanoor mkanoor force-pushed the extend_sasl_mechanisms branch from bbd7d4d to b8c025d Compare October 11, 2025 21:24
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 11, 2025
@github-actions github-actions bot added feat New feature ore request and removed feat New feature ore request labels Oct 11, 2025
files: ^.config\/.*requirements.*$
language: python
language_version: "3.9" # minimal we support officially
language_version: "3.10" # minimal we support officially
Copy link
Contributor

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:
Copy link
Contributor

@Alex-Izquierdo Alex-Izquierdo Oct 14, 2025

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)
Copy link
Contributor

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.

Comment on lines +319 to +342
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)
Copy link
Contributor

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))
Copy link
Contributor

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:
Copy link
Contributor

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

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

Labels

feat New feature ore request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants