You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2021/05/26 10:37:12 UTC

[servicecomb-service-center] branch master updated: SCB-2176 Fix: wrong type definition (#1011)

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

littlecui 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 7db866b  SCB-2176 Fix: wrong type definition (#1011)
7db866b is described below

commit 7db866b8c7f6d910f7b4127db1b329f3cc6677c5
Author: little-cui <su...@qq.com>
AuthorDate: Wed May 26 18:37:06 2021 +0800

    SCB-2176 Fix: wrong type definition (#1011)
---
 server/plugin/auth/auth.go            | 4 ++--
 server/plugin/auth/buildin/buildin.go | 2 +-
 server/plugin/auth/buildin/parser.go  | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/server/plugin/auth/auth.go b/server/plugin/auth/auth.go
index a9fd31b..731002c 100644
--- a/server/plugin/auth/auth.go
+++ b/server/plugin/auth/auth.go
@@ -29,7 +29,7 @@ type Authenticate interface {
 	Identify(r *http.Request) error
 	// ResourceScopes return the scope parsed from request
 	// return nil mean apply all resources
-	ResourceScopes(r *http.Request) []*ResourceScope
+	ResourceScopes(r *http.Request) *ResourceScope
 }
 
 func Auth() Authenticate {
@@ -40,6 +40,6 @@ func Identify(r *http.Request) error {
 	return Auth().Identify(r)
 }
 
-func ResourceScopes(r *http.Request) []*ResourceScope {
+func ResourceScopes(r *http.Request) *ResourceScope {
 	return Auth().ResourceScopes(r)
 }
diff --git a/server/plugin/auth/buildin/buildin.go b/server/plugin/auth/buildin/buildin.go
index 712f158..5476ad7 100644
--- a/server/plugin/auth/buildin/buildin.go
+++ b/server/plugin/auth/buildin/buildin.go
@@ -128,6 +128,6 @@ func mustAuth(pattern string) bool {
 	return rbac.MustAuth(pattern)
 }
 
-func (ba *TokenAuthenticator) ResourceScopes(r *http.Request) []*auth.ResourceScope {
+func (ba *TokenAuthenticator) ResourceScopes(r *http.Request) *auth.ResourceScope {
 	return FromRequest(r)
 }
diff --git a/server/plugin/auth/buildin/parser.go b/server/plugin/auth/buildin/parser.go
index 745e265..a883a39 100644
--- a/server/plugin/auth/buildin/parser.go
+++ b/server/plugin/auth/buildin/parser.go
@@ -44,7 +44,7 @@ func ApplyAll(_ *http.Request) ([]map[string]string, error) {
 	return nil, nil
 }
 
-func FromRequest(r *http.Request) []*auth.ResourceScope {
+func FromRequest(r *http.Request) *auth.ResourceScope {
 	apiPath := r.Context().Value(rest.CtxMatchPattern).(string)
 
 	resource := rbacmodel.GetResource(apiPath)
@@ -53,11 +53,11 @@ func FromRequest(r *http.Request) []*auth.ResourceScope {
 		log.Error(fmt.Sprintf("parse from request failed"), err)
 		return nil
 	}
-	return []*auth.ResourceScope{{
+	return &auth.ResourceScope{
 		Type:   resource,
 		Labels: labels,
 		Verb:   rbac.MethodToVerbs[r.Method],
-	}}
+	}
 }
 
 func GetAPIParseFunc(apiPattern string) ParseFunc {