Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkg/auth/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const (
decisionAllow = "allow"
decisionForbid = "forbid"
reasonError = "internal error"

kubePublicNS = "kube-public"
)

var (
Expand Down Expand Up @@ -182,6 +184,11 @@ func UnprotectedAuthorized(attributes authorizer.Attributes) authorizer.Decision
return authorizer.DecisionAllow
}

// https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
if attributes.GetNamespace() == kubePublicNS && isGetVerb(verb) {
return authorizer.DecisionAllow
}

return authorizer.DecisionNoOpinion
}

Expand Down Expand Up @@ -323,3 +330,7 @@ func splitPath(path string) []string {
}
return strings.Split(path, "/")
}

func isGetVerb(verb string) bool {
return strings.HasPrefix(verb, "get")
}
6 changes: 3 additions & 3 deletions web/console/src/webApi/tkestack.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Request from './request';

export const getTkeStackVersion = async () => {
const rsp = await Request.get<any, { items: Array<{ data?: { tkeVersion?: string } }> }>(
'/api/v1/namespaces/kube-public/configmaps',
const rsp = await Request.get<any, { data?: { tkeVersion: string } }>(
'/api/v1/namespaces/kube-public/configmaps/cluster-info',
{
headers: {
'X-TKE-ClusterName': 'global'
}
}
);
return rsp?.items?.[0]?.data?.tkeVersion ?? '';
return rsp?.data?.tkeVersion ?? '';
};