From c652c2a3113b3ed213b036d19cabff0e09cc6157 Mon Sep 17 00:00:00 2001 From: mountain Date: Wed, 10 Sep 2025 10:58:38 +0900 Subject: [PATCH] =?UTF-8?q?opensearch=20=EA=B3=84=EC=A0=95=EC=9D=B4=20?= =?UTF-8?q?=EC=97=86=EC=9D=84=20=EB=95=8C=20=ED=97=A4=EB=8D=94=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- opensearch/client.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opensearch/client.go b/opensearch/client.go index c2ba28b..0292dec 100644 --- a/opensearch/client.go +++ b/opensearch/client.go @@ -328,13 +328,13 @@ func NewClient(ctx context.Context, cfg Config) (Client, error) { indexPrefix = "ds-logs-" + indexPrefix } - authHeader := fmt.Sprintf("Basic %s", base64.RawURLEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", cfg.Username, cfg.Password)))) - bulkHeader := make(http.Header) - bulkHeader.Set("Authorization", authHeader) - singleHeader := make(http.Header) - singleHeader.Set("Authorization", authHeader) + if len(cfg.Username) > 0 && len(cfg.Password) > 0 { + authHeader := fmt.Sprintf("Basic %s", base64.RawURLEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", cfg.Username, cfg.Password)))) + bulkHeader.Set("Authorization", authHeader) + singleHeader.Set("Authorization", authHeader) + } out := Client{ Client: client,