little-cui commented on code in PR #1461:
URL: 
https://github.com/apache/servicecomb-service-center/pull/1461#discussion_r1536988415


##########
server/plugin/auth/buildin/buildin.go:
##########
@@ -152,13 +157,22 @@ func (ba *TokenAuthenticator) VerifyToken(req 
*http.Request) (interface{}, error
        if v == "" {
                return nil, rbacmodel.NewError(rbacmodel.ErrNoAuthHeader, "")
        }
+       claims, ok := tokenCache.Get(v)
+       if ok {
+               if !claims.(jwt.MapClaims).VerifyExpiresAt(time.Now().Unix(), 
false) {
+                       tokenCache.Delete(v)
+               } else {
+                       return claims, nil
+               }
+       }
        s := strings.Split(v, " ")
        if len(s) != 2 {
                return nil, rbacmodel.ErrInvalidHeader
        }
        to := s[1]
 
        claims, err := authr.Authenticate(req.Context(), to)
+       tokenCache.Set(v, claims, 12*60*time.Minute)
        if err != nil {

Review Comment:
   失败场景,还需要缓存吗?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to