mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Hide consul token on UI. (#2797)
This commit is contained in:
parent
a391156dfb
commit
dbe2eb2afc
|
@ -835,7 +835,7 @@ func (c *FileSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
// ConsulSDConfig is the configuration for Consul service discovery.
|
// ConsulSDConfig is the configuration for Consul service discovery.
|
||||||
type ConsulSDConfig struct {
|
type ConsulSDConfig struct {
|
||||||
Server string `yaml:"server"`
|
Server string `yaml:"server"`
|
||||||
Token string `yaml:"token,omitempty"`
|
Token Secret `yaml:"token,omitempty"`
|
||||||
Datacenter string `yaml:"datacenter,omitempty"`
|
Datacenter string `yaml:"datacenter,omitempty"`
|
||||||
TagSeparator string `yaml:"tag_separator,omitempty"`
|
TagSeparator string `yaml:"tag_separator,omitempty"`
|
||||||
Scheme string `yaml:"scheme,omitempty"`
|
Scheme string `yaml:"scheme,omitempty"`
|
||||||
|
|
|
@ -247,6 +247,7 @@ var expectedConf = &Config{
|
||||||
ConsulSDConfigs: []*ConsulSDConfig{
|
ConsulSDConfigs: []*ConsulSDConfig{
|
||||||
{
|
{
|
||||||
Server: "localhost:1234",
|
Server: "localhost:1234",
|
||||||
|
Token: "mysecret",
|
||||||
Services: []string{"nginx", "cache", "mysql"},
|
Services: []string{"nginx", "cache", "mysql"},
|
||||||
TagSeparator: DefaultConsulSDConfig.TagSeparator,
|
TagSeparator: DefaultConsulSDConfig.TagSeparator,
|
||||||
Scheme: "https",
|
Scheme: "https",
|
||||||
|
@ -542,7 +543,7 @@ func TestLoadConfig(t *testing.T) {
|
||||||
s := c.String()
|
s := c.String()
|
||||||
secretRe := regexp.MustCompile("<secret>")
|
secretRe := regexp.MustCompile("<secret>")
|
||||||
matches := secretRe.FindAllStringIndex(s, -1)
|
matches := secretRe.FindAllStringIndex(s, -1)
|
||||||
if len(matches) != 5 || strings.Contains(s, "mysecret") {
|
if len(matches) != 6 || strings.Contains(s, "mysecret") {
|
||||||
t.Fatalf("config's String method reveals authentication credentials.")
|
t.Fatalf("config's String method reveals authentication credentials.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
config/testdata/conf.good.yml
vendored
1
config/testdata/conf.good.yml
vendored
|
@ -113,6 +113,7 @@ scrape_configs:
|
||||||
|
|
||||||
consul_sd_configs:
|
consul_sd_configs:
|
||||||
- server: 'localhost:1234'
|
- server: 'localhost:1234'
|
||||||
|
token: mysecret
|
||||||
services: ['nginx', 'cache', 'mysql']
|
services: ['nginx', 'cache', 'mysql']
|
||||||
scheme: https
|
scheme: https
|
||||||
tls_config:
|
tls_config:
|
||||||
|
|
|
@ -105,7 +105,7 @@ func NewDiscovery(conf *config.ConsulSDConfig, logger log.Logger) (*Discovery, e
|
||||||
Address: conf.Server,
|
Address: conf.Server,
|
||||||
Scheme: conf.Scheme,
|
Scheme: conf.Scheme,
|
||||||
Datacenter: conf.Datacenter,
|
Datacenter: conf.Datacenter,
|
||||||
Token: conf.Token,
|
Token: string(conf.Token),
|
||||||
HttpAuth: &consul.HttpBasicAuth{
|
HttpAuth: &consul.HttpBasicAuth{
|
||||||
Username: conf.Username,
|
Username: conf.Username,
|
||||||
Password: string(conf.Password),
|
Password: string(conf.Password),
|
||||||
|
|
Loading…
Reference in a new issue