Skip to content

Commit c407978

Browse files
Deprecate username/password when connecting to es (#995)
1 parent 30bd10e commit c407978

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

cmd/fleet/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/elastic/fleet-server/v7/internal/pkg/status"
3737
"github.com/elastic/fleet-server/v7/internal/pkg/ver"
3838

39+
"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
3940
"github.com/elastic/elastic-agent-client/v7/pkg/client"
4041
"github.com/elastic/elastic-agent-client/v7/pkg/proto"
4142
"github.com/hashicorp/go-version"
@@ -559,6 +560,7 @@ func redactOutputCfg(cfg *config.Config) config.Output {
559560
redacted := cfg.Output
560561

561562
if redacted.Elasticsearch.Password != "" {
563+
cfgwarn.Deprecate("8.0.0", "Basic authentication (username:password) is deprecated. Please use api_key.")
562564
redacted.Elasticsearch.Password = kRedacted
563565
}
564566

internal/pkg/es/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/elastic/fleet-server/v7/internal/pkg/build"
1515
"github.com/elastic/fleet-server/v7/internal/pkg/config"
1616

17+
"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
1718
"github.com/elastic/go-elasticsearch/v7"
1819
"github.com/rs/zerolog/log"
1920
)
@@ -22,6 +23,9 @@ type ConfigOption func(config elasticsearch.Config)
2223

2324
func NewClient(ctx context.Context, cfg *config.Config, longPoll bool, opts ...ConfigOption) (*elasticsearch.Client, error) {
2425
escfg, err := cfg.Output.Elasticsearch.ToESConfig(longPoll)
26+
if escfg.Password != "" {
27+
cfgwarn.Deprecate("8.0.0", "Basic authentication (username:password) is deprecated. Please use api_key.")
28+
}
2529
if err != nil {
2630
return nil, err
2731
}

0 commit comments

Comments
 (0)