Skip to content

Commit bdbfb2d

Browse files
authored
fix: Use rest.HTTPClientFor to create TLS-configured client for metrics authentication (#3686)
1 parent ca9fb30 commit bdbfb2d

File tree

2 files changed

+462
-4
lines changed

2 files changed

+462
-4
lines changed

pkg/lib/server/server.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"net/http"
88
"path/filepath"
9-
"time"
109

1110
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/filemonitor"
1211
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/profile"
@@ -110,10 +109,14 @@ func (sc serverConfig) getListenAndServeFunc() (func() error, error) {
110109
// Set up authenticated metrics endpoint if kubeConfig is provided
111110
if sc.kubeConfig != nil && tlsEnabled {
112111
sc.logger.Info("Setting up authenticated metrics endpoint")
112+
// Create HTTP client with proper TLS configuration from kubeConfig
113+
// This is necessary for TokenReview/SubjectAccessReview API calls to verify API server certificates
114+
httpClient, err := rest.HTTPClientFor(sc.kubeConfig)
115+
if err != nil {
116+
return nil, fmt.Errorf("failed to create http client for authentication: %w", err)
117+
}
113118
// Create authentication filter using controller-runtime
114-
filter, err := filters.WithAuthenticationAndAuthorization(sc.kubeConfig, &http.Client{
115-
Timeout: 30 * time.Second,
116-
})
119+
filter, err := filters.WithAuthenticationAndAuthorization(sc.kubeConfig, httpClient)
117120
if err != nil {
118121
return nil, fmt.Errorf("failed to create authentication filter: %w", err)
119122
}

0 commit comments

Comments
 (0)