You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2022/11/09 08:10:54 UTC

[GitHub] [servicecomb-kie] little-cui commented on a diff in pull request #261: 增加RBAC认证

little-cui commented on code in PR #261:
URL: https://github.com/apache/servicecomb-kie/pull/261#discussion_r1017566535


##########
server/datasource/etcd/rbac/acount.go:
##########
@@ -0,0 +1,14 @@
+package rbac

Review Comment:
   缺少license header



##########
server/rbac/account_role.go:
##########
@@ -0,0 +1,79 @@
+package rbac
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	rbacdb "github.com/apache/servicecomb-kie/server/datasource/etcd/rbac"

Review Comment:
   执行goimport



##########
server/rbac/filter_kvdoc.go:
##########
@@ -0,0 +1,36 @@
+package rbac

Review Comment:
   缺少header



##########
server/resource/v1/common.go:
##########
@@ -281,13 +282,23 @@ func queryFromCache(rctx *restful.Context, topic string) {
 	}
 }
 func queryAndResponse(rctx *restful.Context, request *model.ListKVRequest) {
+	permLabels, err := kierbac.GetPermLabels(rctx, kierbac.GetConfigResourceScope())
+	if err != nil {
+		WriteErrResponse(rctx, http.StatusUnauthorized, err.Error())
+		return
+	}
+
 	rev, kv, queryErr := kvsvc.ListKV(rctx.Ctx, request)
 	if queryErr != nil {
 		WriteErrResponse(rctx, queryErr.Code, queryErr.Message)
 		return
 	}
+
+	permKVs := kierbac.FilterKVList(kv.Data, permLabels)

Review Comment:
   只能在datasource层做filter,当前会导致分页逻辑错误



##########
server/rbac/account_role.go:
##########
@@ -0,0 +1,79 @@
+package rbac

Review Comment:
   缺少license header



##########
server/datasource/etcd/rbac/role.go:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package rbac
+
+import (
+	"context"
+	"encoding/json"
+	"errors"
+	"github.com/go-chassis/openlog"

Review Comment:
   格式化goimport



##########
server/rbac/perm.go:
##########
@@ -0,0 +1,36 @@
+package rbac
+
+import (
+	"github.com/go-chassis/go-chassis/v2/server/restful"
+)
+
+func GetPermLabels(rctx *restful.Context, targetResource *ResourceScope) ([]map[string]string, error) {

Review Comment:
   方法的定义本身有问题,名字应该是一个认证性质的词语;另外鉴权的资源没有传递进来,比如我查一个kvID,得判断这个kv是否能跟我们的权限match,不仅仅是我有config权限就行了



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org