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 2019/07/31 07:23:30 UTC

[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1240: [SCB-1318]RSAProviderTokenManager#validatedToken expired resource recycling

liubao68 commented on a change in pull request #1240: [SCB-1318]RSAProviderTokenManager#validatedToken expired resource recycling
URL: https://github.com/apache/servicecomb-java-chassis/pull/1240#discussion_r309071878
 
 

 ##########
 File path: handlers/handler-publickey-auth/src/main/java/org/apache/servicecomb/authentication/provider/RSAProviderTokenManager.java
 ##########
 @@ -50,16 +52,16 @@ public boolean valid(String token) {
         LOGGER.error("token is expired");
         return false;
       }
-      if (validatedToken.contains(rsaToken)) {
+      validatedToken = CacheBuilder.newBuilder()
+          .expireAfterAccess(getExpriredTime(), TimeUnit.MILLISECONDS)
+          .build();
+
+      if (validatedToken.asMap().containsKey(rsaToken)) {
         return accessController.isAllowed(MicroserviceInstanceCache.getOrCreate(rsaToken.getServiceId()));
       }
 
-      String sign = rsaToken.getSign();
-      String content = rsaToken.plainToken();
-      String publicKey = getPublicKey(rsaToken.getInstanceId(), rsaToken.getServiceId());
-      boolean verify = RSAUtils.verify(publicKey, sign, content);
-      if (verify && !tokenExprired(rsaToken)) {
-        validatedToken.add(rsaToken);
+      if (isVerify(rsaToken) && !tokenExprired(rsaToken)) {
+        validatedToken.put(rsaToken, true);
 
 Review comment:
   I think this patch does not fix the problem mentiond in this first commit. Each call to "valid", validatedToken is always empty(newly created).

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services