You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "ChenSammi (via GitHub)" <gi...@apache.org> on 2024/11/05 05:42:26 UTC

[PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

ChenSammi opened a new pull request, #7394:
URL: https://github.com/apache/ozone/pull/7394

   ## What changes were proposed in this pull request?
   With secret key service provided by SCM, using the shared symmetric key to sign and verify delegation token. 
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-8829
   
   ## How was this patch tested?
   
   Existing delegation token tests, plus newly added compatibility unit tests. 
   


-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1841317431


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/security/OzoneDelegationTokenSecretManager.java:
##########
@@ -528,8 +562,17 @@ private void addPersistedDelegationToken(OzoneTokenIdentifier identifier,
           "Can't add persisted delegation token to a running SecretManager.");
     }
 
-    byte[] password = createPassword(identifier.getBytes(),
-        getCertClient().getPrivateKey());
+    byte[] password;
+    if (StringUtils.isNotEmpty(identifier.getSecretKeyId())) {

Review Comment:
   Here, too.



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #7394:
URL: https://github.com/apache/ozone/pull/7394#issuecomment-2481413119

   Thanks @ChenSammi for the patch, @duongkame, @jojochuang for the review.


-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #7394:
URL: https://github.com/apache/ozone/pull/7394#issuecomment-2482295415

   Thanks @adoroszlai @jojochuang @duongkame for the review.   @adoroszlai , thanks for this xcompat test. 


-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1834835413


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/security/SecretKeyManagerService.java:
##########
@@ -158,7 +158,6 @@ public void stop() {
   }
 
   public static boolean isSecretKeyEnable(SecurityConfig conf) {
-    return conf.isSecurityEnabled() &&
-        (conf.isBlockTokenEnabled() || conf.isContainerTokenEnabled());
+    return conf.isSecurityEnabled();

Review Comment:
   why is this changed?



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/OzoneTokenIdentifier.java:
##########
@@ -125,7 +136,13 @@ public OzoneTokenIdentifier fromUniqueSerializedKey(byte[] rawData)
       setStrToSign(WritableUtils.readString(in));
     } else {
       this.tokenType = Type.DELEGATION_TOKEN;
-      setOmCertSerialId(WritableUtils.readString(in));
+      String value = WritableUtils.readString(in);
+      try {
+        UUID.fromString(value);
+        setSecretKeyId(value);
+      } catch (IllegalArgumentException e) {
+        setOmCertSerialId(value);
+      }

Review Comment:
   using exception handling for this case is probably going to be expensive.
   what about:
   ```suggestion
         UUID.fromString(value);
         if (this.omCertSerialId == null || this.secretKeyId == null) {
           setSecretKeyId(value);
         } else {
           setOmCertSerialId(value);
         }
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1837446484


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/OzoneTokenIdentifier.java:
##########
@@ -125,7 +136,13 @@ public OzoneTokenIdentifier fromUniqueSerializedKey(byte[] rawData)
       setStrToSign(WritableUtils.readString(in));
     } else {
       this.tokenType = Type.DELEGATION_TOKEN;
-      setOmCertSerialId(WritableUtils.readString(in));
+      String value = WritableUtils.readString(in);
+      try {
+        UUID.fromString(value);
+        setSecretKeyId(value);
+      } catch (IllegalArgumentException e) {
+        setOmCertSerialId(value);
+      }

Review Comment:
   Because this OzoneTokenIdentifier#toUniqueSerializedKey uses its own raw format instead of OMTokenProto format, which I have no idea how.  In a period of time(7d, max delegation time lifetime) after OM is upgraded to use shared secret key, the same index string would be cerial ID or secreKey ID. So this "  UUID.fromString(value);" used to detect whether it's secretKey, which is a UUID, or a serial ID, which is a number. 



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1841317024


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/security/OzoneDelegationTokenSecretManager.java:
##########
@@ -436,6 +455,21 @@ private TokenInfo validateToken(OzoneTokenIdentifier identifier)
    */
   public boolean verifySignature(OzoneTokenIdentifier identifier,
       byte[] password) {
+    String secretKeyId = identifier.getSecretKeyId();
+    if (StringUtils.isNotEmpty(secretKeyId)) {

Review Comment:
   The PR overall looks good. The only thing I have an opinion about is six months from now, I won't remember why we have an if else statement here. How about making this an intuitive helper method, like 
   ```suggestion
       if (isSymmetricKey(identifier)) {
   ```
   
   or simply add a comment here.



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1843214250


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java:
##########
@@ -46,7 +46,8 @@ public enum OMLayoutFeature implements LayoutFeature {
   FILESYSTEM_SNAPSHOT(5, "Ozone version supporting snapshot"),
 
   QUOTA(6, "Ozone quota re-calculate"),
-  HBASE_SUPPORT(7, "Full support of hsync, lease recovery and listOpenFiles APIs for HBase");
+  HBASE_SUPPORT(7, "Full support of hsync, lease recovery and listOpenFiles APIs for HBase"),
+  DELEGATION_TOKEN_SYMMETRIC_SIGN(8, "Delegation token signed by symmetric key");

Review Comment:
   Thanks @ChenSammi for the great explanation, makes sense.



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1841317024


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/security/OzoneDelegationTokenSecretManager.java:
##########
@@ -436,6 +455,21 @@ private TokenInfo validateToken(OzoneTokenIdentifier identifier)
    */
   public boolean verifySignature(OzoneTokenIdentifier identifier,
       byte[] password) {
+    String secretKeyId = identifier.getSecretKeyId();
+    if (StringUtils.isNotEmpty(secretKeyId)) {

Review Comment:
   The PR overall looks good. The only thing I have an opinion about is six months from now, I won't remember why we have an if else statement here. How about making this an intuitive helper method, like 
   ```suggestion
       if (isSymmetricKey(identifier)) {
   ```
   
   or simply add a Java comment here.



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1837427305


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/security/SecretKeyManagerService.java:
##########
@@ -158,7 +158,6 @@ public void stop() {
   }
 
   public static boolean isSecretKeyEnable(SecurityConfig conf) {
-    return conf.isSecurityEnabled() &&
-        (conf.isBlockTokenEnabled() || conf.isContainerTokenEnabled());
+    return conf.isSecurityEnabled();

Review Comment:
   Before this patch, secretKey service only starts when block token or container token is enabled. With this patch, secretKey should start only when security is enabled, for delegation token is by default enabled when security is enabled. 



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1837630079


##########
hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto:
##########
@@ -1458,6 +1458,7 @@ message OMTokenProto {
     optional string signature      = 13;
     optional string strToSign      = 14;
     optional string omServiceId    = 15;
+    optional string secretKeyId    = 16;

Review Comment:
   Right



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1842370150


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java:
##########
@@ -46,7 +46,8 @@ public enum OMLayoutFeature implements LayoutFeature {
   FILESYSTEM_SNAPSHOT(5, "Ozone version supporting snapshot"),
 
   QUOTA(6, "Ozone quota re-calculate"),
-  HBASE_SUPPORT(7, "Full support of hsync, lease recovery and listOpenFiles APIs for HBase");
+  HBASE_SUPPORT(7, "Full support of hsync, lease recovery and listOpenFiles APIs for HBase"),
+  DELEGATION_TOKEN_SYMMETRIC_SIGN(8, "Delegation token signed by symmetric key");

Review Comment:
   I may be missing something, but why is this an `OMLayoutFeature`?  Is there any permanent change at the server-side that needs to be finalized after upgrade before we can start using symmetric keys?



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "duongkame (via GitHub)" <gi...@apache.org>.
duongkame commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1833544138


##########
hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto:
##########
@@ -1458,6 +1458,7 @@ message OMTokenProto {
     optional string signature      = 13;
     optional string strToSign      = 14;
     optional string omServiceId    = 15;
+    optional string secretKeyId    = 16;

Review Comment:
   Deprecated `omCertSerialId`?



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/OzoneTokenIdentifier.java:
##########
@@ -326,6 +359,18 @@ public String getOmCertSerialId() {
 
   public void setOmCertSerialId(String omCertSerialId) {
     this.omCertSerialId = omCertSerialId;
+    Preconditions.checkArgument(this.omCertSerialId == null || this.secretKeyId == null,

Review Comment:
   nit: this would not validate it. Imagine you have `omCertSerialId` already set, then call `setOmCertSerialId`. The condition is passed because of the `||` operator.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/security/OzoneDelegationTokenSecretManager.java:
##########
@@ -195,9 +209,15 @@ public Token<OzoneTokenIdentifier> createToken(Text owner, Text renewer,
     OzoneTokenIdentifier identifier = createIdentifier(owner, renewer,
         realUser);
     updateIdentifierDetails(identifier);
-
-    byte[] password = createPassword(identifier.getBytes(),
-        getCurrentKey().getPrivateKey());
+    byte[] password;
+    if (ozoneManager.getVersionManager().isAllowed(OMLayoutFeature.DELEGATION_TOKEN_SYMMETRIC_SIGN)) {

Review Comment:
   We may not need a new layout version. This looks like a compatible change.



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1837450725


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/security/OzoneDelegationTokenSecretManager.java:
##########
@@ -195,9 +209,15 @@ public Token<OzoneTokenIdentifier> createToken(Text owner, Text renewer,
     OzoneTokenIdentifier identifier = createIdentifier(owner, renewer,
         realUser);
     updateIdentifierDetails(identifier);
-
-    byte[] password = createPassword(identifier.getBytes(),
-        getCurrentKey().getPrivateKey());
+    byte[] password;
+    if (ozoneManager.getVersionManager().isAllowed(OMLayoutFeature.DELEGATION_TOKEN_SYMMETRIC_SIGN)) {

Review Comment:
   The token signed by symmetric keys and token signed by asymmetric keys are incompatible at server side.  Delegation tokens are relatively long lived token, default 7d.  If a client get a delegation signed by symmetric keys after OM upgrade but before finalize, later this OM upgrade is cancelled, then when the token client held sent to the OM again after downgrade,  it cannot be verified by OM, client execution will fail.  All type of tokens are opaque to client.  The new DELEGATION_TOKEN_SYMMETRIC_SIGN layout is introduced to handle the compatibility between lower version of OM and high version of OM.



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai merged PR #7394:
URL: https://github.com/apache/ozone/pull/7394


-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1837450557


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/OzoneTokenIdentifier.java:
##########
@@ -326,6 +359,18 @@ public String getOmCertSerialId() {
 
   public void setOmCertSerialId(String omCertSerialId) {
     this.omCertSerialId = omCertSerialId;
+    Preconditions.checkArgument(this.omCertSerialId == null || this.secretKeyId == null,

Review Comment:
   The check here is to make sure a OzoneTokenIdentifier cannot have both omCertSerialId  and secretKeyId set.  It can only have one of them. 



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #7394:
URL: https://github.com/apache/ozone/pull/7394#issuecomment-2476900544

   BTW, here is a simple update for the `xcompat` test to cover delegation tokens, would be nice to add it to the patch.
   
   ```diff
   diff --git hadoop-ozone/dist/src/main/smoketest/compatibility/read.robot hadoop-ozone/dist/src/main/smoketest/compatibility/read.robot
   index e56465bb8b..00f5408bc6 100644
   --- hadoop-ozone/dist/src/main/smoketest/compatibility/read.robot
   +++ hadoop-ozone/dist/src/main/smoketest/compatibility/read.robot
   @@ -46,3 +46,8 @@ FSO Bucket Can Be Read
        Execute    ozone fs -get ofs://om/vol1/fso-bucket-${SUFFIX}/dir/subdir/file ${TEMP_DIR}/
        Execute    diff -q ${TESTFILE} ${TEMP_DIR}/file
        [teardown]    Execute    rm -f ${TEMP_DIR}/file
   +
   +Delegation Token Can Be Renewed
   +    Execute    ozone sh key get -f /vol1/bucket1/token-${SUFFIX} ${TEMP_DIR}/token
   +    Execute    ozone sh token renew --token ${TEMP_DIR}/token
   +    [teardown]    Execute    rm -f ${TEMP_DIR}/token
   diff --git hadoop-ozone/dist/src/main/smoketest/compatibility/write.robot hadoop-ozone/dist/src/main/smoketest/compatibility/write.robot
   index a44901a99a..0453f00c0d 100644
   --- hadoop-ozone/dist/src/main/smoketest/compatibility/write.robot
   +++ hadoop-ozone/dist/src/main/smoketest/compatibility/write.robot
   @@ -40,3 +40,8 @@ FSO Bucket Can Be Created and Used
        Execute    ozone sh bucket create --layout FILE_SYSTEM_OPTIMIZED /vol1/fso-bucket-${SUFFIX}
        Execute    ozone fs -mkdir -p ofs://om/vol1/fso-bucket-${SUFFIX}/dir/subdir
        Execute    ozone fs -put ${TESTFILE} ofs://om/vol1/fso-bucket-${SUFFIX}/dir/subdir/file
   +
   +Delegation Token Can Be Obtained
   +    [setup]    Execute    rm -f ${TEMP_DIR}/token
   +    Execute    ozone sh token get --token ${TEMP_DIR}/token
   +    Execute    ozone sh key put /vol1/bucket1/token-${SUFFIX} ${TEMP_DIR}/token
   ```
   
   I've run this with `old_versions="1.4.0"` only, assuming all prior releases have the same behavior for tokens.  Both `token get` and `token renew` works well.


-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1843114270


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutFeature.java:
##########
@@ -46,7 +46,8 @@ public enum OMLayoutFeature implements LayoutFeature {
   FILESYSTEM_SNAPSHOT(5, "Ozone version supporting snapshot"),
 
   QUOTA(6, "Ozone quota re-calculate"),
-  HBASE_SUPPORT(7, "Full support of hsync, lease recovery and listOpenFiles APIs for HBase");
+  HBASE_SUPPORT(7, "Full support of hsync, lease recovery and listOpenFiles APIs for HBase"),
+  DELEGATION_TOKEN_SYMMETRIC_SIGN(8, "Delegation token signed by symmetric key");

Review Comment:
   The token signed by symmetric keys and token signed by asymmetric keys are incompatible at server side. Delegation tokens are relatively long lived token, default 7d. If a client get a delegation signed by symmetric keys after OM upgrade but before finalize, later this OM upgrade is cancelled, then when the token client held sent to the OM again after downgrade, it cannot be verified by OM, client execution will fail. All type of tokens are opaque to client. The new DELEGATION_TOKEN_SYMMETRIC_SIGN layout is introduced to handle the compatibility between lower version of OM and high version of OM.



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #7394:
URL: https://github.com/apache/ozone/pull/7394#issuecomment-2456568168

   Please wait for clean CI run in fork before opening PR (or marking "ready for review").
   
   https://github.com/ChenSammi/ozone/actions/runs/11678259968
   https://github.com/ChenSammi/ozone/actions/runs/11678501108


-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1834864431


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/OzoneTokenIdentifier.java:
##########
@@ -125,7 +136,13 @@ public OzoneTokenIdentifier fromUniqueSerializedKey(byte[] rawData)
       setStrToSign(WritableUtils.readString(in));
     } else {
       this.tokenType = Type.DELEGATION_TOKEN;
-      setOmCertSerialId(WritableUtils.readString(in));
+      String value = WritableUtils.readString(in);
+      try {
+        UUID.fromString(value);
+        setSecretKeyId(value);
+      } catch (IllegalArgumentException e) {
+        setOmCertSerialId(value);
+      }

Review Comment:
   Oh wait this is not right. Why does it call UUID.fromString() and ignore the return value?



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #7394:
URL: https://github.com/apache/ozone/pull/7394#issuecomment-2469543765

   > work
   
   
   
   > will a new client work with an old OM? In this case the client would fill both omCertSerialId and secretKeyId fields, OM would return a token based on the old implementation, so that keeps the old behavior, but at least that's not a regression. So it should work right?
   
   A new client work with an old OM will get an old RSA signed delegation token. And old RSA signed delegation token can be verified by both old OM and new OM.  It will work.
   


-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1838390767


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/OzoneTokenIdentifier.java:
##########
@@ -125,7 +136,13 @@ public OzoneTokenIdentifier fromUniqueSerializedKey(byte[] rawData)
       setStrToSign(WritableUtils.readString(in));
     } else {
       this.tokenType = Type.DELEGATION_TOKEN;
-      setOmCertSerialId(WritableUtils.readString(in));
+      String value = WritableUtils.readString(in);
+      try {
+        UUID.fromString(value);
+        setSecretKeyId(value);
+      } catch (IllegalArgumentException e) {
+        setOmCertSerialId(value);
+      }

Review Comment:
   I was going to suggest to use Integer.isNumeric(). But it throws an exception internally so it ends up the same.



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1837446484


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/OzoneTokenIdentifier.java:
##########
@@ -125,7 +136,13 @@ public OzoneTokenIdentifier fromUniqueSerializedKey(byte[] rawData)
       setStrToSign(WritableUtils.readString(in));
     } else {
       this.tokenType = Type.DELEGATION_TOKEN;
-      setOmCertSerialId(WritableUtils.readString(in));
+      String value = WritableUtils.readString(in);
+      try {
+        UUID.fromString(value);
+        setSecretKeyId(value);
+      } catch (IllegalArgumentException e) {
+        setOmCertSerialId(value);
+      }

Review Comment:
   Because this OzoneTokenIdentifier#toUniqueSerializedKey uses its own raw format instead of OMTokenProto format, which I have no idea how.  In a period of time(7d, max delegation time lifetime) after OM is upgraded to use shared secret key, the same index string would be cerial ID or secreKey ID. So this "  UUID.fromString(value);" used to detect whether it's secretKey, which is a UUID, or a serial ID, which is a number. 
   
   Let me further check if we can refactor some existing code, to avoid this  UUID.fromString(value) being executed after upgrade 7days. 



-- 
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: issues-unsubscribe@ozone.apache.org

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


Re: [PR] HDDS-8829. Symmetric Keys for Delegation Tokens [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #7394:
URL: https://github.com/apache/ozone/pull/7394#discussion_r1837446484


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/OzoneTokenIdentifier.java:
##########
@@ -125,7 +136,13 @@ public OzoneTokenIdentifier fromUniqueSerializedKey(byte[] rawData)
       setStrToSign(WritableUtils.readString(in));
     } else {
       this.tokenType = Type.DELEGATION_TOKEN;
-      setOmCertSerialId(WritableUtils.readString(in));
+      String value = WritableUtils.readString(in);
+      try {
+        UUID.fromString(value);
+        setSecretKeyId(value);
+      } catch (IllegalArgumentException e) {
+        setOmCertSerialId(value);
+      }

Review Comment:
   Because this OzoneTokenIdentifier#toUniqueSerializedKey uses its own raw format instead of OMTokenProto format, which I have no idea why.  In a period of time(7d, max delegation time lifetime) after OM is upgraded to use shared secret key, the same index string would be cerial ID or secreKey ID. So this "  UUID.fromString(value);" used to detect whether it's secretKey, which is a UUID, or a serial ID, which is a number. 
   
   Let me further check if we can refactor some existing code, to avoid this  UUID.fromString(value) being executed after upgrade 7days. 



-- 
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: issues-unsubscribe@ozone.apache.org

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