@@ -13,7 +13,9 @@ import (
1313// This provider requires users to provide authentication tokens via request headers.
1414// It uses cluster connection details from configuration but does not use any
1515// authentication credentials from kubeconfig files.
16- type AuthHeadersClusterProvider struct {}
16+ type AuthHeadersClusterProvider struct {
17+ staticConfig * config.StaticConfig
18+ }
1719
1820var _ Provider = & AuthHeadersClusterProvider {}
1921
@@ -85,7 +87,7 @@ func newAuthHeadersClusterProvider(cfg *config.StaticConfig) (Provider, error) {
8587
8688 klog .V (1 ).Infof ("Auth-headers provider initialized - all requests must include valid headers" )
8789
88- return & AuthHeadersClusterProvider {}, nil
90+ return & AuthHeadersClusterProvider {staticConfig : cfg }, nil
8991}
9092
9193func (p * AuthHeadersClusterProvider ) IsOpenShift (ctx context.Context ) bool {
@@ -106,11 +108,57 @@ func (p *AuthHeadersClusterProvider) GetTargetParameterName() string {
106108}
107109
108110func (p * AuthHeadersClusterProvider ) GetDerivedKubernetes (ctx context.Context , target string ) (* Kubernetes , error ) {
109- // _, err := New(ctx)
111+ // authHeaders, ok := ctx.Value(AuthHeadersContextKey).(*K8sAuthHeaders)
112+ // if !ok {
113+ // return nil, errors.New("authHeaders required")
114+ // }
115+
116+ // decodedCA, err := authHeaders.GetDecodedCertificateAuthorityData()
110117 // if err != nil {
111- // return nil, err
118+ // return nil, fmt.Errorf("failed to decode certificate authority data: %w", err)
119+ // }
120+
121+ // restConfig := &rest.Config{
122+ // Host: authHeaders.ClusterURL,
123+ // BearerToken: authHeaders.AuthorizationToken,
124+ // TLSClientConfig: rest.TLSClientConfig{
125+ // Insecure: false,
126+ // CAData: decodedCA,
127+ // },
112128 // }
113129
130+ // _ := clientcmd.NewDefaultClientConfig(*restConfig, nil)
131+
132+ // // Create a REST config with only cluster connection details (no auth)
133+ // restConfig := &rest.Config{
134+ // Host: cluster.Server,
135+ // APIPath: m.cfg.APIPath,
136+ // TLSClientConfig: rest.TLSClientConfig{
137+ // Insecure: cluster.InsecureSkipTLSVerify,
138+ // ServerName: cluster.TLSServerName,
139+ // CAData: cluster.CertificateAuthorityData,
140+ // CAFile: cluster.CertificateAuthority,
141+ // },
142+ // UserAgent: rest.DefaultKubernetesUserAgent(),
143+ // QPS: m.cfg.QPS,
144+ // Burst: m.cfg.Burst,
145+ // Timeout: m.cfg.Timeout,
146+ // }
147+
148+ // // Create a minimal clientcmd config without any authentication
149+ // minimalConfig := clientcmdapi.NewConfig()
150+ // minimalConfig.Clusters["cluster"] = &clientcmdapi.Cluster{
151+ // Server: cluster.Server,
152+ // InsecureSkipTLSVerify: cluster.InsecureSkipTLSVerify,
153+ // CertificateAuthority: cluster.CertificateAuthority,
154+ // CertificateAuthorityData: cluster.CertificateAuthorityData,
155+ // TLSServerName: cluster.TLSServerName,
156+ // }
157+ // minimalConfig.Contexts["auth-headers-context"] = &clientcmdapi.Context{
158+ // Cluster: "cluster",
159+ // }
160+ // minimalConfig.CurrentContext = "auth-headers-context"
161+
114162 // derivedCfg := &rest.Config{
115163 // Host: authHeaders.ClusterURL,
116164 // APIPath: m.cfg.APIPath,
0 commit comments