-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[fix] Enable Kafka TLS when TLS auth is specified #2107
Changes from all commits
0042cd3
5b48422
4e170e9
5dc88cb
4c760ad
7e8c615
1f1a6f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
package kafka | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
|
@@ -23,6 +24,8 @@ import ( | |
"github.com/stretchr/testify/require" | ||
|
||
"github.com/jaegertracing/jaeger/pkg/config" | ||
"github.com/jaegertracing/jaeger/pkg/config/tlscfg" | ||
"github.com/jaegertracing/jaeger/pkg/kafka/auth" | ||
) | ||
|
||
func TestOptionsWithFlags(t *testing.T) { | ||
|
@@ -164,3 +167,44 @@ func TestRequiredAcksFailures(t *testing.T) { | |
_, err := getRequiredAcks("test") | ||
assert.Error(t, err) | ||
} | ||
|
||
func TestTLSFlags(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests are duplicated. Don't we have Kafka flags parsed by a packaged shared between ingester and storage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both tests are in different packages, there is no shared test class. |
||
kerb := auth.KerberosConfig{ServiceName: "kafka", ConfigPath: "/etc/krb5.conf", KeyTabPath: "/etc/security/kafka.keytab"} | ||
tests := []struct { | ||
flags []string | ||
expected auth.AuthenticationConfig | ||
}{ | ||
{ | ||
flags: []string{}, | ||
expected: auth.AuthenticationConfig{Authentication: "none", Kerberos: kerb}, | ||
}, | ||
{ | ||
flags: []string{"--kafka.producer.authentication=foo"}, | ||
expected: auth.AuthenticationConfig{Authentication: "foo", Kerberos: kerb}, | ||
}, | ||
{ | ||
flags: []string{"--kafka.producer.authentication=kerberos", "--kafka.producer.tls.enabled=true"}, | ||
expected: auth.AuthenticationConfig{Authentication: "kerberos", Kerberos: kerb, TLS: tlscfg.Options{Enabled: true}}, | ||
}, | ||
{ | ||
flags: []string{"--kafka.producer.authentication=tls"}, | ||
expected: auth.AuthenticationConfig{Authentication: "tls", Kerberos: kerb, TLS: tlscfg.Options{Enabled: true}}, | ||
}, | ||
{ | ||
flags: []string{"--kafka.producer.authentication=tls", "--kafka.producer.tls.enabled=false"}, | ||
expected: auth.AuthenticationConfig{Authentication: "tls", Kerberos: kerb, TLS: tlscfg.Options{Enabled: true}}, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(fmt.Sprintf("%s", test.flags), func(t *testing.T) { | ||
o := &Options{} | ||
v, command := config.Viperize(o.AddFlags) | ||
err := command.ParseFlags(test.flags) | ||
require.NoError(t, err) | ||
o.InitFromViper(v) | ||
assert.Equal(t, test.expected, o.config.AuthenticationConfig) | ||
|
||
}) | ||
} | ||
} |
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 means that if someone explicitly set
tls.enabled
tofalse, this will be silently changed to
true`. I have nothing against that, but perhaps there's a way to detect whether this value was explicitly provided and keep whatever the user set?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.
it can be done by changing the
enabled
property to a pointer. I am not sure if there is much value in it. Some signatures will have to be also changed to accept the logger.More controversial is this setting
Somebody omitting the auth type and specifying
tls.enabled=true
.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.
@yurishkuro any thoughts on this? I don't have a strong opinion whether
kafka.consumer.tls.enabled=true
should setkafka.consumer.authentication=tls
.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.
From Gitter, we just saw a case where a user wants TLS encryption between the agent and collector without the auth parts.
kafka.producer.tls.enabled=true
+kafka.producer.authentication=none
is a valid combination.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.
You are right, it's confusing for people to have both
kafka.producer.tls.enabled
andkafka.producer.authentication
they will probably tend to forget the second one.I have updated the PR to set
tls
auth when.tls.enabled
istrue
.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.
It's the opposite.
tls.enabled
does not implyauthentication=tls
. It's perfectly possible to haveauthentication=none
but the traffic be encrypted using TLS.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.
@jpkrohling I am not sure if I understand you...
This is exactly what the PR does.
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.
Sorry, I misunderstood you, you are absolutely correct :-)