-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add kafka kerberos authentication support for collector/ingester
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
- Loading branch information
1 parent
7f2a49d
commit b68c652
Showing
9 changed files
with
337 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requires connection to Kafka |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2019 The Jaeger Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package auth | ||
|
||
import ( | ||
"log" | ||
"strings" | ||
|
||
"github.com/Shopify/sarama" | ||
) | ||
|
||
const none = "none" | ||
const kerberos = "kerberos" | ||
|
||
// AuthenticationConfig describes the configuration properties needed authenticate with kafka cluster | ||
type AuthenticationConfig struct { | ||
Authentication string | ||
Kerberos KerberosConfig | ||
} | ||
|
||
//SetConfiguration set configure authentication into sarama config structure | ||
func SetConfiguration(config AuthenticationConfig, saramaConfig *sarama.Config) { | ||
authentication := strings.ToLower(config.Authentication) | ||
if strings.Trim(authentication, " ") == "" { | ||
authentication = none | ||
} | ||
switch authentication { | ||
case kerberos: | ||
setKerberosConfiguration(&config.Kerberos, saramaConfig) | ||
case none: | ||
return | ||
} | ||
log.Fatalf("Unknown/Unsupported authentication method %s to kafka cluster.", config.Authentication) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2019 The Jaeger Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package auth | ||
|
||
import ( | ||
"github.com/Shopify/sarama" | ||
) | ||
|
||
// KerberosConfig describes the configuration properties needed for Kerberos authentication with kafka consumer | ||
type KerberosConfig struct { | ||
ServiceName string | ||
Realm string | ||
UseKeyTab bool | ||
Username string | ||
Password string | ||
ConfigPath string | ||
KeyTabPath string | ||
} | ||
|
||
func setKerberosConfiguration(config *KerberosConfig, saramaConfig *sarama.Config) { | ||
saramaConfig.Net.SASL.Mechanism = sarama.SASLTypeGSSAPI | ||
if config.UseKeyTab { | ||
saramaConfig.Net.SASL.GSSAPI.KeyTabPath = config.KeyTabPath | ||
saramaConfig.Net.SASL.GSSAPI.AuthType = sarama.KRB5_KEYTAB_AUTH | ||
} else { | ||
saramaConfig.Net.SASL.GSSAPI.AuthType = sarama.KRB5_USER_AUTH | ||
saramaConfig.Net.SASL.GSSAPI.KeyTabPath = config.Password | ||
} | ||
saramaConfig.Net.SASL.GSSAPI.KerberosConfigPath = config.ConfigPath | ||
saramaConfig.Net.SASL.GSSAPI.Username = config.Username | ||
saramaConfig.Net.SASL.GSSAPI.Realm = config.Realm | ||
saramaConfig.Net.SASL.GSSAPI.ServiceName = config.ServiceName | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.