This is an automated email from the ASF dual-hosted git repository.
ChenSammi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 92d1f2e1790 HDDS-17408. Revoke must not lower STS revocation cutoff
(#12011)
92d1f2e1790 is described below
commit 92d1f2e1790f2c4a6e1174bf5fc1781c29aaed2b
Author: fmorg-git <[email protected]>
AuthorDate: Sat Nov 14 01:02:28 2026 -0800
HDDS-17408. Revoke must not lower STS revocation cutoff (#12011)
---
.../s3/security/S3RevokeSTSTokenRequest.java | 18 ++++----
.../s3/security/TestS3RevokeSTSTokenRequest.java | 48 ++++++++++++++++++++++
2 files changed, 59 insertions(+), 7 deletions(-)
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/security/S3RevokeSTSTokenRequest.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/security/S3RevokeSTSTokenRequest.java
index eedcdc1be42..d176fb339fb 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/security/S3RevokeSTSTokenRequest.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/security/S3RevokeSTSTokenRequest.java
@@ -27,8 +27,6 @@
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
-import org.apache.hadoop.hdds.utils.db.cache.CacheKey;
-import org.apache.hadoop.hdds.utils.db.cache.CacheValue;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.audit.OMAction;
import org.apache.hadoop.ozone.om.OzoneManager;
@@ -107,15 +105,21 @@ public OMClientResponse
validateAndUpdateCache(OzoneManager ozoneManager, Execut
final RevokeSTSTokenRequest revokeReq =
validateReplicatedRevokeRequestFields(getOmRequest());
final String originalAccessKeyId = revokeReq.getOriginalAccessKeyId();
auditMap.put(OzoneConsts.S3_REVOKESTSTOKEN_USER, originalAccessKeyId);
- final long revocationTimeMillis = revokeReq.getRevocationTimeMillis();
+ // Update the cache immediately so subsequent validation checks see the
revocation
+ final Long cutoff = S3SecretRequestHelper.updateStsRevocationCutoff(
+ ozoneManager.getMetadataManager(), getOmRequest(),
originalAccessKeyId, context.getIndex());
+ if (cutoff == null) {
+ // This branch should not be reachable because of the checks in
validateReplicatedRevokeRequestFields, but is
+ // here as a defensive mechanism (in case someone mistakenly removes
that code, etc.). It returns
+ // INTERNAL_ERROR error code because the leader should have provided
the replicated revoke STS request
+ // (which is how updateStsRevocationCutoff could return null), not the
client
+ throw new OMException("internal error in STS token revocation",
INTERNAL_ERROR);
+ }
+ final long revocationTimeMillis = cutoff;
// All actual DB mutations are done in the response's addToDBBatch().
omClientResponse = new S3RevokeSTSTokenResponse(originalAccessKeyId,
revocationTimeMillis, omResponse.build());
- // Update the cache immediately so subsequent validation checks see the
revocation
-
ozoneManager.getMetadataManager().getS3RevokedStsTokenTable().addCacheEntry(
- new CacheKey<>(originalAccessKeyId),
CacheValue.get(context.getIndex(), revocationTimeMillis));
-
LOG.info(
"Marked STS tokens as revoked for originalAccessKeyId={} with cutoff
time {}.",
originalAccessKeyId, revocationTimeMillis);
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/s3/security/TestS3RevokeSTSTokenRequest.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/s3/security/TestS3RevokeSTSTokenRequest.java
index 58a28539733..22fb30d0909 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/s3/security/TestS3RevokeSTSTokenRequest.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/s3/security/TestS3RevokeSTSTokenRequest.java
@@ -552,6 +552,48 @@ public void testPurgeKeepsCutoffEqualToPurgeBeforeMillis()
throws Exception {
}
}
+ @Test
+ public void testRevokeWithLowerStampKeepsStoredCutoff() throws Exception {
+ // Revokes can be applied with stamps that do not increase in log order; a
lower stamp must not lower the cutoff.
+ final String originalAccessKeyId = "original-access-key-id";
+ final long base = 1_700_000_000_000L;
+ final OmMetadataManagerImpl omMetadataManager = createMetadataManager();
+ try {
+ final OzoneManager ozoneManager = mockOzoneManager(omMetadataManager);
+ final Table<String, Long> table =
omMetadataManager.getS3RevokedStsTokenTable();
+
+ flush(omMetadataManager, 1L, revoke(ozoneManager, 1L,
originalAccessKeyId, base + 1_000L));
+ assertCutoff(table, originalAccessKeyId, base + 1_000L);
+
+ flush(omMetadataManager, 2L, revoke(ozoneManager, 2L,
originalAccessKeyId, base));
+ assertCutoff(table, originalAccessKeyId, base + 1_000L);
+
+ flush(omMetadataManager, 3L, revoke(ozoneManager, 3L,
originalAccessKeyId, base + 2_000L));
+ assertCutoff(table, originalAccessKeyId, base + 2_000L);
+ } finally {
+ omMetadataManager.stop();
+ }
+ }
+
+ @Test
+ public void testRevokeWithLowerStampBeforeFlushKeepsCachedCutoff() throws
Exception {
+ // The higher cutoff is still only in the cache when the lower stamp is
applied, and the DB must end up with it.
+ final String originalAccessKeyId = "original-access-key-id";
+ final long higherCutoff = 1_700_000_000_000L;
+ final OmMetadataManagerImpl omMetadataManager = createMetadataManager();
+ try {
+ final OzoneManager ozoneManager = mockOzoneManager(omMetadataManager);
+ final OMClientResponse higherRevoke = revoke(ozoneManager, 1L,
originalAccessKeyId, higherCutoff);
+ final OMClientResponse lowerRevoke = revoke(ozoneManager, 2L,
originalAccessKeyId, higherCutoff - 1_000L);
+ flush(omMetadataManager, 1L, higherRevoke);
+ flush(omMetadataManager, 2L, lowerRevoke);
+
+ assertCutoff(omMetadataManager.getS3RevokedStsTokenTable(),
originalAccessKeyId, higherCutoff);
+ } finally {
+ omMetadataManager.stop();
+ }
+ }
+
private OmMetadataManagerImpl createMetadataManager() throws IOException {
final OzoneConfiguration conf = new OzoneConfiguration();
conf.set(OMConfigKeys.OZONE_OM_DB_DIRS,
folder.toAbsolutePath().toString());
@@ -614,6 +656,12 @@ private static Set<String> cachedKeys(Table<String, Long>
table) {
return keys;
}
+ private static void assertCutoff(Table<String, Long> table, String
originalAccessKeyId, long expectedCutoff)
+ throws IOException {
+
assertThat(table.getIfExist(originalAccessKeyId)).isEqualTo(expectedCutoff);
+
assertThat(table.getSkipCache(originalAccessKeyId)).isEqualTo(expectedCutoff);
+ }
+
private static void assertRevokedEntryFullyRemoved(Table<String, Long>
table, String originalAccessKeyId)
throws Exception {
assertThat(table.getIfExist(originalAccessKeyId)).isNull();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]