xiaoyuyao commented on a change in pull request #1672:
URL: https://github.com/apache/ozone/pull/1672#discussion_r539565286



##########
File path: 
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/token/BlockTokenVerifier.java
##########
@@ -118,7 +125,19 @@ public void verify(String user, String tokenStr,
           " by user: " + tokenUser);
     }
 
-    // TODO: check cmd type and the permissions(AccessMode) in the token
+    if (cmd == ReadChunk || cmd == GetBlock || cmd == GetSmallFile) {
+      if (!tokenId.getAccessModes().contains(
+          HddsProtos.BlockTokenSecretProto.AccessModeProto.READ)) {
+        throw new BlockTokenException("Block token with " + id
+            + " doesn't have READ permission");
+      }
+    } else if (cmd == WriteChunk || cmd == PutBlock || cmd == PutSmallFile) {
+      if (!tokenId.getAccessModes().contains(
+          HddsProtos.BlockTokenSecretProto.AccessModeProto.WRITE)) {
+        throw new BlockTokenException("Block token with " + id
+            + " doesn't have WRITE permission");
+      }
+    }

Review comment:
       good point. Even though the check block token was not currently done for 
other cmd, the third else will ensure proper handling is added if this is 
changed in future. 




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to