You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/12/09 18:57:56 UTC

[GitHub] [ozone] xiaoyuyao commented on a change in pull request #1672: HDDS-4558. Support Ozone block token with access mode check.

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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org