You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by di...@apache.org on 2026/10/24 00:11:49 UTC

(polaris) branch main updated: NoSQL: Honor the stored credential-rotation flag when rotating secrets (#5835)

This is an automated email from the ASF dual-hosted git repository.

dimas-b pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 4363adb3c6 NoSQL: Honor the stored credential-rotation flag when rotating secrets (#5835)
4363adb3c6 is described below

commit 4363adb3c67866e9edeb3925b00edbfa17416f60
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Sat Oct 24 05:41:44 2026 +0530

    NoSQL: Honor the stored credential-rotation flag when rotating secrets (#5835)
    
    A principal created with credentialRotationRequired is blocked by
    CredentialRotationFilter until it rotates its credentials, and that rotation is
    meant to invalidate the secret the administrator handed over. The relational-JDBC
    and transactional backends implement this by deciding the reset from the caller's
    argument or the stored state, doReset = reset || storedState, so the forced
    rotation drops the previous secret instead of moving it into the secondary slot.
    
    The NoSQL backend decided it from the argument alone. A principal performing its
    required rotation therefore kept the previously issued secret as its secondary
    secret, which still authenticates, while the rotation state was cleared so
    nothing revisited it. The state itself was already read in the same statement to
    compute the new flag value, so only the reset decision diverged.
    
    The shared metastore test fixture already creates its principal with the rotation
    state set and rotates it, but only asserted that the main secret changed and the
    flag was cleared. It now also asserts that the previously issued secret is no
    longer held as the secondary secret, the guard it already applies to an
    explicitly requested reset.
---
 CHANGELOG.md                                                       | 4 ++++
 .../polaris/persistence/nosql/metastore/NoSqlMetaStoreManager.java | 7 +++++--
 .../polaris/core/persistence/PolarisTestMetaStoreManager.java      | 7 +++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7ee6c8b78..176f84b4bb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -252,6 +252,10 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
   generic-table paths used by the Spark plugin, now encode spaces in namespace and table names as
   `%20` instead of `+`. Previously, credential refresh failed for tables whose namespace or name
   contained a space.
+- NoSQL: a required credential rotation now invalidates the previous secret. The stored
+  credential-rotation state was not considered when deciding whether to drop the previous secret,
+  so the secret issued before the rotation stayed usable as the principal's secondary secret,
+  unlike on the relational-JDBC and transactional backends.
 - The MongoDB readiness check is now shown in `/q/health` only when the NoSQL MongoDB backend is
   selected. Other persistence backends no longer show the unused check. MongoDB deployments keep
   readiness monitoring without configuration changes.
diff --git a/persistence/nosql/persistence/metastore/src/main/java/org/apache/polaris/persistence/nosql/metastore/NoSqlMetaStoreManager.java b/persistence/nosql/persistence/metastore/src/main/java/org/apache/polaris/persistence/nosql/metastore/NoSqlMetaStoreManager.java
index 27aeba3256..2277e9e8a8 100644
--- a/persistence/nosql/persistence/metastore/src/main/java/org/apache/polaris/persistence/nosql/metastore/NoSqlMetaStoreManager.java
+++ b/persistence/nosql/persistence/metastore/src/main/java/org/apache/polaris/persistence/nosql/metastore/NoSqlMetaStoreManager.java
@@ -655,9 +655,12 @@ record NoSqlMetaStoreManager(
           (principal, updatedPrincipalBuilder) -> {
             var principalSecrets = principalObjToPolarisPrincipalSecrets(principal);
 
-            // rotate the secrets
+            // rotate the secrets, dropping the previous secret when the principal is required to
+            // rotate its credentials, so the secret issued before does not remain usable as the
+            // secondary secret
+            var doReset = reset || principal.credentialRotationRequired();
             principalSecrets.rotateSecrets(oldSecretHash);
-            if (reset) {
+            if (doReset) {
               principalSecrets.rotateSecrets(principalSecrets.getMainSecretHash());
             }
 
diff --git a/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/PolarisTestMetaStoreManager.java b/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/PolarisTestMetaStoreManager.java
index d90c24283d..007c62f4a7 100644
--- a/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/PolarisTestMetaStoreManager.java
+++ b/polaris-core/src/testFixtures/java/org/apache/polaris/core/persistence/PolarisTestMetaStoreManager.java
@@ -501,6 +501,13 @@ public class PolarisTestMetaStoreManager {
             .getPrincipalSecrets();
     Assertions.assertThat(secrets.getMainSecret()).isNotEqualTo(reloadSecrets.getMainSecret());
 
+    PolarisPrincipalSecrets afterRequiredRotation =
+        polarisMetaStoreManager
+            .loadPrincipalSecrets(this.polarisCallContext, clientId)
+            .getPrincipalSecrets();
+    Assertions.assertThat(afterRequiredRotation.getSecondarySecretHash())
+        .isNotEqualTo(reloadSecrets.getMainSecretHash());
+
     PrincipalEntity reloadPrincipal =
         polarisMetaStoreManager
             .findPrincipalById(