Skip to content

Commit

Permalink
Feat: add ClientIdentityPenetration flag
Browse files Browse the repository at this point in the history
Signed-off-by: Yin Da <[email protected]>
  • Loading branch information
Somefive committed May 25, 2022
1 parent f6dd1c5 commit bea0066
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pkg/apis/cluster/v1alpha1/clustergateway_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import (
"strings"
"time"

utilfeature "k8s.io/apiserver/pkg/util/feature"

"github.com/oam-dev/cluster-gateway/pkg/config"
"github.com/oam-dev/cluster-gateway/pkg/featuregates"
"github.com/oam-dev/cluster-gateway/pkg/metrics"

"github.com/pkg/errors"
Expand Down Expand Up @@ -216,7 +219,7 @@ func (p *proxyHandler) ServeHTTP(writer http.ResponseWriter, request *http.Reque
responsewriters.InternalError(writer, request, errors.Wrapf(err, "failed creating cluster proxy client config %s", cluster.Name))
return
}
if p.impersonate {
if p.impersonate || utilfeature.DefaultFeatureGate.Enabled(featuregates.ClientIdentityPenetration) {
cfg.Impersonate = getImpersonationConfig(request)
}
rt, err := restclient.TransportFor(cfg)
Expand Down
12 changes: 10 additions & 2 deletions pkg/featuregates/featue_gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ const (
// SecretCache runs a namespaced secret informer inside the apiserver which
// provides a cache for reading secret data.
SecretCache featuregate.Feature = "SecretCache"

// owner: @somefive
// alpha: v1.4.0
//
// ClientIdentityPenetration enforce impersonate as the original request user
// when accessing apiserver in ManagedCluster
ClientIdentityPenetration featuregate.Feature = "ClientIdentityPenetration"
)

var DefaultKubeFedFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
HealthinessCheck: {Default: false, PreRelease: featuregate.Alpha},
SecretCache: {Default: true, PreRelease: featuregate.Beta},
HealthinessCheck: {Default: false, PreRelease: featuregate.Alpha},
SecretCache: {Default: true, PreRelease: featuregate.Beta},
ClientIdentityPenetration: {Default: false, PreRelease: featuregate.Alpha},
}

0 comments on commit bea0066

Please sign in to comment.