diff --git a/pkg/auth/filter/filter.go b/pkg/auth/filter/filter.go index 4c76ab5174..52fc5bc1ad 100644 --- a/pkg/auth/filter/filter.go +++ b/pkg/auth/filter/filter.go @@ -60,6 +60,8 @@ const ( decisionAllow = "allow" decisionForbid = "forbid" reasonError = "internal error" + + kubePublicNS = "kube-public" ) var ( @@ -182,6 +184,11 @@ func UnprotectedAuthorized(attributes authorizer.Attributes) authorizer.Decision return authorizer.DecisionAllow } + // https://kubernetes.io/docs/reference/setup-tools/kubeadm/implementation-details/ + if attributes.GetNamespace() == kubePublicNS && isGetVerb(verb) { + return authorizer.DecisionAllow + } + return authorizer.DecisionNoOpinion } @@ -323,3 +330,7 @@ func splitPath(path string) []string { } return strings.Split(path, "/") } + +func isGetVerb(verb string) bool { + return strings.HasPrefix(verb, "get") +} diff --git a/web/console/src/webApi/tkestack.ts b/web/console/src/webApi/tkestack.ts index 4973365921..cb17aa7449 100644 --- a/web/console/src/webApi/tkestack.ts +++ b/web/console/src/webApi/tkestack.ts @@ -1,13 +1,13 @@ import Request from './request'; export const getTkeStackVersion = async () => { - const rsp = await Request.get }>( - '/api/v1/namespaces/kube-public/configmaps', + const rsp = await Request.get( + '/api/v1/namespaces/kube-public/configmaps/cluster-info', { headers: { 'X-TKE-ClusterName': 'global' } } ); - return rsp?.items?.[0]?.data?.tkeVersion ?? ''; + return rsp?.data?.tkeVersion ?? ''; };