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

feat: add support for SASL SCRAM 256 and 512 for Kafka #1518

Merged
merged 8 commits into from
Feb 27, 2024

Conversation

Dnomyar
Copy link
Contributor

@Dnomyar Dnomyar commented Feb 21, 2024

Hey folks,

First, thanks for this project!

I am proposing to add support for SASL SCRAM 256 and 512 for the Kafka connector.
I only tested SASL SCRAM 512 with a source (not a sink).

There are a few things that are missing:

  • tests
  • some code is duplicated

This is my first time doing Go so I appreciate any feedback

Cheers

Signed-off-by: Damien Raymond <damien.raymond@paddypowerbetfair.com>
pkg/apis/numaflow/v1alpha1/sasl.go Outdated Show resolved Hide resolved
pkg/apis/numaflow/v1alpha1/sasl.go Outdated Show resolved Hide resolved
Signed-off-by: Damien Raymond <damien.raymond@paddypowerbetfair.com>
Copy link
Contributor

@vigith vigith left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the contribution :)

@vigith
Copy link
Contributor

vigith commented Feb 22, 2024

@KeranYang KeranYang changed the title Add support for SASL SCRAM 256 and 512 for Kafka feat: add support for SASL SCRAM 256 and 512 for Kafka Feb 22, 2024
Damien Raymond added 2 commits February 26, 2024 16:09
Signed-off-by: Damien Raymond <damien.raymond@paddypowerbetfair.com>
sasl_config: extracted setting username and password, added tests
volume: created interface to allow to mock reading from the filesystem

Signed-off-by: Damien Raymond <damien.raymond@paddypowerbetfair.com>
@Dnomyar Dnomyar marked this pull request as ready for review February 26, 2024 16:11
@Dnomyar
Copy link
Contributor Author

Dnomyar commented Feb 26, 2024

I have updated the docs and added some tests.

Could you indicate how should I fix conflicts for the go.sum, please? I am not so familiar with go

@vigith
Copy link
Contributor

vigith commented Feb 26, 2024

i have resolved it

@vigith
Copy link
Contributor

vigith commented Feb 26, 2024

can you do a git-pull and run make codegen ?

Signed-off-by: Damien Raymond <damien.raymond@paddypowerbetfair.com>
@@ -30,9 +30,20 @@ var (
configMapKeySelectorType = reflect.TypeOf(&corev1.ConfigMapKeySelector{})
)

type GetSecrets interface {
Copy link
Member

Choose a reason for hiding this comment

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

  1. I assume the purpose of the interface is to be able to mock it for testing? If that's the case, make it and OsFile?
  2. The name does not match the 2 functions.

Copy link
Contributor Author

@Dnomyar Dnomyar Feb 27, 2024

Choose a reason for hiding this comment

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

I assume the purpose of the interface is to be able to mock it for testing?

yes I added that as a comment

If that's the case, make it and OsFile?

Sorry, I don't understand, what you mean by that

The name does not match the 2 functions.

I renamed to volumeReader, what do you think?

}

// GetSASLConfig A utility function to get sarama.Config.Net.SASL
func GetSASLStrategy[GetSecretsStrategy GetSecrets](saslConfig *dfv1.SASL, strategy GetSecretsStrategy) (*struct {
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason you use generics instead of just writing it as:

func GetSASLStrategy(saslConfig *dfv1.SASL, strategy GetSecrets) (*struct {
...

Copy link
Member

Choose a reason for hiding this comment

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

Also, make the function private.

Copy link
Contributor Author

@Dnomyar Dnomyar Feb 27, 2024

Choose a reason for hiding this comment

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

What is the reason you use generics instead of just writing it as:

That's a very good point! Changed!

Also, make the function private.

I went through the code I changed the visibility of things that should be private

}

// GetSASLConfig A utility function to get sarama.Config.Net.SASL
func GetSASLStrategy[GetSecretsStrategy GetSecrets](saslConfig *dfv1.SASL, strategy GetSecretsStrategy) (*struct {
Copy link
Member

Choose a reason for hiding this comment

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

Also, make the function private.

default:
return nil, fmt.Errorf("SASL mechanism not supported: %s", *saslConfig.Mechanism)
}
return &config.Net.SASL, nil
}

func SetUserPassword[GetSecretsStrategy GetSecrets](config *sarama.Config, userSecret *corev1.SecretKeySelector, passwordSecret *corev1.SecretKeySelector, strategy GetSecretsStrategy) error {
Copy link
Member

Choose a reason for hiding this comment

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

Make it private.

// GetSecretFromVolume retrieves the value of mounted secret volume
// "/var/numaflow/secrets/${secretRef.name}/${secretRef.key}" is expected to be the file path
func GetSecretFromVolume(selector *corev1.SecretKeySelector) (string, error) {
func (_ OsFile) GetSecretFromVolume(selector *corev1.SecretKeySelector) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Using underscore will bring warning in some IDEs.

Copy link
Contributor Author

@Dnomyar Dnomyar Feb 27, 2024

Choose a reason for hiding this comment

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

Using underscore will bring warning in some IDEs.

I thought the underscore was required, changed!

Signed-off-by: Damien Raymond <damien.raymond@paddypowerbetfair.com>
@Dnomyar
Copy link
Contributor Author

Dnomyar commented Feb 27, 2024

Thanks for you feedback @whynowy! I think I have fixed most things. Let me know if I forgot anything

Copy link
Member

@whynowy whynowy left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@vigith vigith enabled auto-merge (squash) February 27, 2024 18:16
@vigith
Copy link
Contributor

vigith commented Feb 27, 2024

thank you @Dnomyar for your contribution. Would you like to add your use-case to https://github.com/numaproj/numaflow/blob/main/USERS.md?

@vigith vigith merged commit 5b31bac into numaproj:main Feb 27, 2024
20 checks passed
whynowy pushed a commit that referenced this pull request Feb 27, 2024
Signed-off-by: Damien Raymond <damien.raymond@paddypowerbetfair.com>
Co-authored-by: Damien Raymond <damien.raymond@paddypowerbetfair.com>
@syayi
Copy link
Contributor

syayi commented Feb 29, 2024

Thank you @Dnomyar for the contribution! We're keen to hear about your experience with Numaflow and gather feedback, would you be open for a chat?

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.

None yet

4 participants