This is an automated email from the ASF dual-hosted git repository.

tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git


The following commit(s) were added to refs/heads/master by this push:
     new 7bb8c4e  rbac frame pkg should not import un necessary pkg (#678)
7bb8c4e is described below

commit 7bb8c4eb9421306eb46ae4de4390408b745a01af
Author: Shawn <[email protected]>
AuthorDate: Mon Aug 17 10:58:35 2020 +0800

    rbac frame pkg should not import un necessary pkg (#678)
---
 pkg/rbacframe/api_test.go   | 4 ++--
 pkg/rbacframe/context.go    | 6 +-----
 server/service/rbac/rbac.go | 2 +-
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/pkg/rbacframe/api_test.go b/pkg/rbacframe/api_test.go
index f1d775d..f9be3ef 100644
--- a/pkg/rbacframe/api_test.go
+++ b/pkg/rbacframe/api_test.go
@@ -49,8 +49,8 @@ func TestMustAuth(t *testing.T) {
        rbacframe.Add2WhiteAPIList("/test")
        assert.False(t, rbacframe.MustAuth("/test"))
        assert.True(t, rbacframe.MustAuth("/auth"))
-       assert.False(t, rbacframe.MustAuth("/version"))
-       assert.False(t, rbacframe.MustAuth("/v4/a/registry/health"))
+       assert.True(t, rbacframe.MustAuth("/version"))
+       assert.True(t, rbacframe.MustAuth("/v4/a/registry/health"))
 }
 
 func TestAuthenticate(t *testing.T) {
diff --git a/pkg/rbacframe/context.go b/pkg/rbacframe/context.go
index 82d059e..4f13dba 100644
--- a/pkg/rbacframe/context.go
+++ b/pkg/rbacframe/context.go
@@ -19,7 +19,6 @@ package rbacframe
 
 import (
        "context"
-       context2 
"github.com/apache/servicecomb-service-center/server/handler/context"
        "k8s.io/apimachinery/pkg/util/sets"
 )
 
@@ -50,8 +49,5 @@ func Add2WhiteAPIList(path ...string) {
 }
 
 func MustAuth(pattern string) bool {
-       if whiteAPIList.Has(pattern) {
-               return false
-       }
-       return !context2.IsSkip(pattern)
+       return !whiteAPIList.Has(pattern)
 }
diff --git a/server/service/rbac/rbac.go b/server/service/rbac/rbac.go
index e741b7c..a666e19 100644
--- a/server/service/rbac/rbac.go
+++ b/server/service/rbac/rbac.go
@@ -70,7 +70,7 @@ func Init() {
        }
        readPrivateKey()
        readPublicKey()
-       rbacframe.Add2WhiteAPIList("/v4/token")
+       rbacframe.Add2WhiteAPIList("/health", "/version", "/v4/token")
        log.Info("rbac is enabled")
 }
 func initResourceMap() {

Reply via email to