Skip to content

Plain SASL mechanism fails for writer #533

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

Closed
cemremengu opened this issue Oct 10, 2020 · 2 comments
Closed

Plain SASL mechanism fails for writer #533

cemremengu opened this issue Oct 10, 2020 · 2 comments
Assignees
Labels

Comments

@cemremengu
Copy link

cemremengu commented Oct 10, 2020

Describe the bug
Plain auth mechanisim producing the error below on the server, failing to auth

Invalid SASL/PLAIN response: expected 3 tokens, got 4) (org.apache.kafka.common.network.Selector)

Kafka Version
cp-kafka (docker) 6.0.0

To Reproduce
Try creating a new writer with plain mechanism

	w := kafka.NewWriter(kafka.WriterConfig{
		Brokers:          opts.Brokers,
		Topic:            "xxx",
		Balancer:         &kafka.RoundRobin{},
		BatchSize:        500,
		BatchTimeout:     10 * time.Millisecond,
		CompressionCodec: snappy.NewCompressionCodec(),
		Dialer: &kafka.Dialer{
			Timeout: 10 * time.Second,
			SASLMechanism: plain.Mechanism{
				Username: opts.Username,
				Password: opts.Password,
			},
		},
	})

Expected behavior
Dialer by itself works fine

	mechanism := plain.Mechanism{
		Username: "admin",
		Password: "xxxx",
	}

	dialer := &kafka.Dialer{
		Timeout:       10 * time.Second,
		DualStack:     true,
		SASLMechanism: mechanism,
	}

	conn, err := dialer.DialContext(context.Background(), "tcp", url)

Additional context
Seems like authorizationIdFromClient is missing ?

https://github.com/a0x8o/kafka/blob/master/clients/src/main/java/org/apache/kafka/common/security/plain/PlainSaslServer.java#L93

@cemremengu cemremengu added the bug label Oct 10, 2020
@cemremengu cemremengu changed the title Writer plain mechanism fails Plain SASL mechanism fails for writer Oct 10, 2020
@godwhoa
Copy link

godwhoa commented Nov 1, 2020

Was able to reproduce this locally so did some digging, v0.4.1 to v0.4.5 have this bug. v0.3.x, v0.4.0 and >=v0.4.6 don't have this bug.

Edit: Looks like this is a dup of #499 which got fixed in v0.4.6.

@achille-roussel achille-roussel self-assigned this Feb 12, 2021
@achille-roussel
Copy link
Contributor

Thanks for reporting @cemremengu, and following up on the issue @godwhoa!

Since this has been fixed in later versions of kafka-go, I will be closing the issue. Feel free to reopen if you are still encountering problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants