From dc6d3d1966ff4c6e68b51f7275ed248689bf8998 Mon Sep 17 00:00:00 2001 From: tornado-ssy <64736788+tornado-ssy@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:47:10 +0800 Subject: [PATCH] [fix] fix the problem of can not require the api of kie when open rbac (#1486) --- server/plugin/auth/buildin/buildin.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/plugin/auth/buildin/buildin.go b/server/plugin/auth/buildin/buildin.go index e22e26681..776513cd9 100644 --- a/server/plugin/auth/buildin/buildin.go +++ b/server/plugin/auth/buildin/buildin.go @@ -175,7 +175,13 @@ func (ba *TokenAuthenticator) VerifyToken(req *http.Request) (interface{}, error return nil, rbacmodel.NewError(rbacmodel.ErrNoAuthHeader, "") } claims, ok := tokenCache.Get(v) + s := strings.Split(v, " ") + if len(s) != 2 { + return nil, rbacmodel.ErrInvalidHeader + } + to := s[1] if ok { + token.WithRequest(req, to) switch claimsVal := claims.(type) { case error: return nil, claimsVal @@ -183,11 +189,6 @@ func (ba *TokenAuthenticator) VerifyToken(req *http.Request) (interface{}, error return claimsVal, nil } } - s := strings.Split(v, " ") - if len(s) != 2 { - return nil, rbacmodel.ErrInvalidHeader - } - to := s[1] claims, err := authr.Authenticate(req.Context(), to) if err != nil {