Closed suxiangdong closed 1 year ago
It looks like Sarama does not enforce the response is empty. Per RFC-4616, the server does not send a challenge. I guess it can just be ignored.
What error do you get with this patch: https://github.com/twmb/franz-go/commit/ec2ba2f9b7a6226828d93598fccfcb24a4f76be8 ? (be sure to strip any password if Tencent is returning that in the response)
I have another branch: https://github.com/twmb/franz-go/tree/plain_challenge_detail but if I can change the patch to be specific to something Tencent is saying, then I will do some string comparison rather than removing the check entirely.
What error do you get with this patch: ec2ba2f ? (be sure to strip any password if Tencent is returning that in the response)
I have another branch: https://github.com/twmb/franz-go/tree/plain_challenge_detail but if I can change the patch to be specific to something Tencent is saying, then I will do some string comparison rather than removing the check entirely.
The error message returned contains the username and password used for authentication. I have removed the sensitive information.
error:
[DEBUG] opening connection to broker; addr: kafkaconsumer-ap-guangzhou.cls.tencentcs.com:9096, broker: seed 0
[INFO] immediate metadata update triggered; why: querying metadata for consumer initialization
[DEBUG] connection opened to broker; addr: kafkaconsumer-ap-guangzhou.cls.tencentcs.com:9096, broker: seed 0
[DEBUG] issuing api versions request; broker: seed 0, version: 3
[DEBUG] wrote ApiVersions v3; broker: seed 0, bytes_written: 61, write_wait: 61.792µs, time_to_write: 26.208µs, err: <nil>
[DEBUG] read ApiVersions v3; broker: seed 0, bytes_read: 114, read_wait: 132.292µs, time_to_read: 69.705958ms, err: <nil>
[DEBUG] issuing SASLHandshakeRequest; broker: seed 0
[DEBUG] wrote SASLHandshake v1; broker: seed 0, bytes_written: 24, write_wait: 37.75µs, time_to_write: 29.709µs, err: <nil>
[DEBUG] read SASLHandshake v1; broker: seed 0, bytes_read: 23, read_wait: 38.416µs, time_to_read: 70.716084ms, err: <nil>
[DEBUG] beginning sasl authentication; broker: seed 0, addr: kafkaconsumer-ap-guangzhou.cls.tencentcs.com:9096, mechanism: PLAIN, authenticate: true
[DEBUG] issuing SASLAuthenticate; broker: seed 0, version: 0, step: 0
[DEBUG] wrote SASLAuthenticate v0; broker: seed 0, bytes_written: 128, write_wait: 68.292µs, time_to_write: 38.833µs, err: <nil>
[DEBUG] read SASLAuthenticate v0; broker: seed 0, bytes_read: 123, read_wait: 40.667µs, time_to_read: 97.642417ms, err: <nil>
[ERROR] unable to initialize sasl; broker: seed 0, err: unexpected data in plain response: "\x00${USERNAME}\x00${PASSWORD}"
[DEBUG] connection initialization failed; addr: kafkaconsumer-ap-guangzhou.cls.tencentcs.com:9096, broker: seed 0, err: unexpected data in plain response: "\x00${USERNAME}\x00${PASSWORD}"
[DEBUG] opening connection to broker; addr: kafkaconsumer-ap-guangzhou.cls.tencentcs.com:9096, broker: seed 0
It looks like Sarama does not enforce the response is empty. Per RFC-4616, the server does not send a challenge. I guess it can just be ignored.
After ignoring the challenge, it works fine. Is the server side not supposed to return information? In RFC-4616, I didn't quite understand where it was specified.
Strange. No, it's not expected to return the information. 4422 dictates that extra information should be explained -- 4616 does not include any explanation for extra information. If you pinned Sarama to v0.11, I think Sarama would also fail -- Sarama's v0 enforces no extra data in the response (Sarama actually enforces four null bytes for the v0 version of sasl handshake, but four null bytes corresponds to "no size").
I'll do a bit more checking today and if I can't find anything, I guess it can be fine to ignore the unexpected response... maybe. I'll think about it.
I get it, thanks.
I can temporarily fork the repository to use in my project. If ignoring this unexpected response can be implemented within franz-go, I'm switching back.
It looks like
complete = true
first, and then skips any data in the response because complete == trueI can skip the data, I'll release a patch for this
Okay, thanks.
Sorry for the delay, busy lately. I'll see about trying to close this out today.
When consuming cls (Tencent's logging service) data via kafka protocol, authentication fails using "sasl_plaintext" protocol. However, with the same configuration, using sarama library can authenticate and consume data normally. I can't find the problem and need your help, thanks.
https://cloud.tencent.com/document/product/614/72651
version: sarama: v1.38.1 franz-go: v1.10.0
sarama demo:
franz-go demo:
error: