-
Notifications
You must be signed in to change notification settings - Fork 839
Added support for SASL PLAIN and SCRAM mechanisms #223
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
Conversation
Initial contribution that provides a skeleton for SASL support. For more information about the authentication sequence, please see https://kafka.apache.org/protocol#sasl_handshake
Also ensured that adding support for new mechanisms in the future is as straightforward as possible.
achille-roussel
left a comment
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 great 👍 Thanks for taking care of it!
sasl/scram/scram.go
Outdated
|
|
||
| // HashFunction determines the hash function used by SCRAM to protect the user's | ||
| // credentials. | ||
| type HashFunction int |
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.
Any reasons not to make this an interface with implementations for the SHA256 and SHA512 hash functions instead of an enum type?
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.
I did have reasons...the most important of which was to make sure we didn't export anything 3rd party libraries (e.g. in case we swap out scram providers later). But I think that can also be done with an interface. I just pushed up what I would see as the interface version...let me know which you prefer!
sasl/scram/scram.go
Outdated
| // | ||
| // SCRAM-SHA-256 and SCRAM-SHA-512 were added to Kafka in 0.10.2.0. These | ||
| // mechanisms will not work with older versions. | ||
| func Mechanism(algo Algorithm, username, password string) (*mechanism, error) { |
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.
Exposing an unexported type in the return value here is a bit weird, was this intended?
* moved Mechanism -> sasl.Mechanism * moved common test code -> testing package * return sasl.Mechanism in scram constructor instead of *mechanism
This PR picks up the work on the inactive PR #134 in order to drive it to conclusion.