File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ const (
6060 decisionAllow = "allow"
6161 decisionForbid = "forbid"
6262 reasonError = "internal error"
63+
64+ kubePublicNS = "kube-public"
6365)
6466
6567var (
@@ -182,6 +184,11 @@ func UnprotectedAuthorized(attributes authorizer.Attributes) authorizer.Decision
182184 return authorizer .DecisionAllow
183185 }
184186
187+ // https://kubernetes.io/docs/reference/setup-tools/kubeadm/implementation-details/
188+ if attributes .GetNamespace () == kubePublicNS && isGetVerb (verb ) {
189+ return authorizer .DecisionAllow
190+ }
191+
185192 return authorizer .DecisionNoOpinion
186193}
187194
@@ -323,3 +330,7 @@ func splitPath(path string) []string {
323330 }
324331 return strings .Split (path , "/" )
325332}
333+
334+ func isGetVerb (verb string ) bool {
335+ return strings .HasPrefix (verb , "get" )
336+ }
Original file line number Diff line number Diff line change 11import Request from './request' ;
22
33export const getTkeStackVersion = async ( ) => {
4- const rsp = await Request . get < any , { items : Array < { data ?: { tkeVersion ? : string } } > } > (
5- '/api/v1/namespaces/kube-public/configmaps' ,
4+ const rsp = await Request . get < any , { data ?: { tkeVersion : string } } > (
5+ '/api/v1/namespaces/kube-public/configmaps/cluster-info ' ,
66 {
77 headers : {
88 'X-TKE-ClusterName' : 'global'
99 }
1010 }
1111 ) ;
12- return rsp ?. items ?. [ 0 ] ?. data ?. tkeVersion ?? '' ;
12+ return rsp ?. data ?. tkeVersion ?? '' ;
1313} ;
You can’t perform that action at this time.
0 commit comments