Skip to content

Commit e06d051

Browse files
authored
Fix kubecube authorization (#35)
* add cluster info when request to kubecube for pod authorization * add changelog
1 parent c9c022d commit e06d051

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# v1.2.4
2+
2022-8-31
3+
## Bugfix:
4+
- add cluster info when request to kubecube for pod authorization
5+
## Dependency:
6+
- kubecube 1.4.0
7+
18
# v1.2.3
29
2022-7-19
310
## Enhance:

handler/auth.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type attributes struct {
4747
Name string `json:"name"`
4848
ResourceRequest bool `json:"resourceRequest"`
4949
Path string `json:"path"`
50+
Cluster string `json:"cluster"`
5051
}
5152

5253
// podAuthorityVerify verify whether current user could access to pod
@@ -76,8 +77,15 @@ func isAuthValid(request *restful.Request) bool {
7677
return false
7778
}
7879
namespace := request.PathParameter(NamespaceKey)
79-
attribute := &attributes{user, "get", namespace, "", "", "pods",
80-
"", "", true, ""}
80+
cluster := request.PathParameter(ClusterKey)
81+
attribute := &attributes{
82+
User: user,
83+
Verb: "get",
84+
Namespace: namespace,
85+
Resource: "pods",
86+
ResourceRequest: true,
87+
Cluster: cluster,
88+
}
8189
bytesData, err := json.Marshal(attribute)
8290
if err != nil {
8391
clog.Error("marshal json error: %s", err)

handler/metadata.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const (
3232
LeaderElectionKey = "kubecube-webconsole-leader-election-key"
3333
LeaderElectionNamespace = "kube-system"
3434
NamespaceKey = "namespace"
35+
ClusterKey = "cluster"
3536
KubeCubeChrootShPath = "/kubecube-chroot.sh"
3637
CloudShellLabelKey = "kubecube.io/app"
3738
)

0 commit comments

Comments
 (0)