mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -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.
|
||||
type ConsulSDConfig struct {
|
||||
Server string `yaml:"server"`
|
||||
Token string `yaml:"token,omitempty"`
|
||||
Token Secret `yaml:"token,omitempty"`
|
||||
Datacenter string `yaml:"datacenter,omitempty"`
|
||||
TagSeparator string `yaml:"tag_separator,omitempty"`
|
||||
Scheme string `yaml:"scheme,omitempty"`
|
||||
|
|
|
@ -247,6 +247,7 @@ var expectedConf = &Config{
|
|||
ConsulSDConfigs: []*ConsulSDConfig{
|
||||
{
|
||||
Server: "localhost:1234",
|
||||
Token: "mysecret",
|
||||
Services: []string{"nginx", "cache", "mysql"},
|
||||
TagSeparator: DefaultConsulSDConfig.TagSeparator,
|
||||
Scheme: "https",
|
||||
|
@ -542,7 +543,7 @@ func TestLoadConfig(t *testing.T) {
|
|||
s := c.String()
|
||||
secretRe := regexp.MustCompile("<secret>")
|
||||
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.")
|
||||
}
|
||||
|
||||
|
|
1
config/testdata/conf.good.yml
vendored
1
config/testdata/conf.good.yml
vendored
|
@ -113,6 +113,7 @@ scrape_configs:
|
|||
|
||||
consul_sd_configs:
|
||||
- server: 'localhost:1234'
|
||||
token: mysecret
|
||||
services: ['nginx', 'cache', 'mysql']
|
||||
scheme: https
|
||||
tls_config:
|
||||
|
|
|
@ -105,7 +105,7 @@ func NewDiscovery(conf *config.ConsulSDConfig, logger log.Logger) (*Discovery, e
|
|||
Address: conf.Server,
|
||||
Scheme: conf.Scheme,
|
||||
Datacenter: conf.Datacenter,
|
||||
Token: conf.Token,
|
||||
Token: string(conf.Token),
|
||||
HttpAuth: &consul.HttpBasicAuth{
|
||||
Username: conf.Username,
|
||||
Password: string(conf.Password),
|
||||
|
|
Loading…
Reference in a new issue