Skip to content

Commit 440e942

Browse files
committed
fix(kubepi): 权限过滤修改
1 parent 3d2ffdc commit 440e942

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

internal/api/v1/v1.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8-
"github.com/KubeOperator/kubepi/internal/api/v1/file"
9-
"github.com/KubeOperator/kubepi/internal/api/v1/mfa"
108
"io/ioutil"
119
"strings"
1210

11+
"github.com/KubeOperator/kubepi/internal/api/v1/file"
12+
"github.com/KubeOperator/kubepi/internal/api/v1/mfa"
13+
1314
"github.com/kataras/iris/v12/middleware/jwt"
1415

1516
"github.com/KubeOperator/kubepi/internal/api/v1/chart"
@@ -312,9 +313,14 @@ func roleAccessHandler() iris.Handler {
312313
//// 通过api resource 过滤出来资源主体,method 过滤操作
313314
p := ctx.Values().Get("profile")
314315
u := p.(session.UserProfile)
315-
if !strings.Contains(ctx.Request().URL.Path, "/proxy") && !strings.Contains(ctx.Request().URL.Path, "/ws") &&
316-
!strings.Contains(ctx.Request().URL.Path, "/webkubectl") && !strings.Contains(ctx.Request().URL.Path, "/webkubectl") &&
317-
!strings.Contains(ctx.Request().URL.Path, "/charts") && !strings.Contains(ctx.Request().URL.Path, "/apps") {
316+
isInWhiteList := false
317+
for _, path := range resourceWhiteList {
318+
if strings.Contains(ctx.Request().URL.Path, fmt.Sprintf("/%s", path)) && path != "sessions" {
319+
isInWhiteList = true
320+
break
321+
}
322+
}
323+
if !isInWhiteList {
318324
// 放通admin权限
319325
if u.IsAdministrator {
320326
ctx.Next()

0 commit comments

Comments
 (0)