You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by ad...@apache.org on 2026/10/05 12:51:27 UTC
(polaris) branch main updated: Prevent dropping or renaming the root principal (#5687)
This is an automated email from the ASF dual-hosted git repository.
adutra 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 5aab91dafe Prevent dropping or renaming the root principal (#5687)
5aab91dafe is described below
commit 5aab91dafecf498c0c94af62dc4c6e0cf9868a96
Author: Prithvi S <pr...@gmail.com>
AuthorDate: Mon Oct 5 18:21:22 2026 +0530
Prevent dropping or renaming the root principal (#5687)
Realm bootstrap identifies a bootstrapped realm by the presence of a principal named root. Dropping or renaming it caused every newly started process to treat the realm as not bootstrapped, and re-running bootstrap could not cleanly repair it. Protect it like the service_admin and catalog_admin roles via cannotBeDroppedOrRenamed().
---
CHANGELOG.md | 5 ++
.../polaris/core/entity/PolarisEntityCore.java | 11 ++-
.../polaris/core/entity/PolarisEntityCoreTest.java | 88 ++++++++++++++++++++++
3 files changed, 101 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b491ffce12..eeabab9880 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -83,6 +83,11 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
### Fixes
+- The `root` principal can no longer be dropped or renamed. Realm bootstrap identifies a
+ bootstrapped realm by the presence of a principal named `root`, so removing or renaming it caused
+ every newly started process to treat the realm as not bootstrapped (failing all requests,
+ including the token endpoint), and re-running bootstrap could not cleanly repair it. It is now
+ protected like the `service_admin` and `catalog_admin` roles.
- Deleting an external catalog now also deletes the inline connection secrets (OAuth client secret
or bearer token) that were written to the `UserSecretsManager` when the catalog was created.
Previously they stayed in the secrets store with no entity referencing them.
diff --git a/polaris-core/src/main/java/org/apache/polaris/core/entity/PolarisEntityCore.java b/polaris-core/src/main/java/org/apache/polaris/core/entity/PolarisEntityCore.java
index 4c53de2765..f5fe7d8745 100644
--- a/polaris-core/src/main/java/org/apache/polaris/core/entity/PolarisEntityCore.java
+++ b/polaris-core/src/main/java/org/apache/polaris/core/entity/PolarisEntityCore.java
@@ -151,15 +151,20 @@ public class PolarisEntityCore implements Identifiable {
}
/**
- * @return true if this entity cannot be dropped or renamed. Applies to the admin catalog role and
- * the polaris service admin principal role.
+ * @return true if this entity cannot be dropped or renamed. Applies to the admin catalog role,
+ * the polaris service admin principal role, and the root principal. The root principal is
+ * protected because realm bootstrap identifies a bootstrapped realm by the presence of a
+ * principal named {@code root}: dropping or renaming it makes every freshly started process
+ * treat the realm as not bootstrapped, and re-running bootstrap cannot cleanly repair it.
*/
@JsonIgnore
public boolean cannotBeDroppedOrRenamed() {
return (this.typeCode == PolarisEntityType.CATALOG_ROLE.getCode()
&& this.name.equals(PolarisEntityConstants.getNameOfCatalogAdminRole()))
|| (this.typeCode == PolarisEntityType.PRINCIPAL_ROLE.getCode()
- && this.name.equals(PolarisEntityConstants.getNameOfPrincipalServiceAdminRole()));
+ && this.name.equals(PolarisEntityConstants.getNameOfPrincipalServiceAdminRole()))
+ || (this.typeCode == PolarisEntityType.PRINCIPAL.getCode()
+ && this.name.equals(PolarisEntityConstants.getRootPrincipalName()));
}
/**
diff --git a/polaris-core/src/test/java/org/apache/polaris/core/entity/PolarisEntityCoreTest.java b/polaris-core/src/test/java/org/apache/polaris/core/entity/PolarisEntityCoreTest.java
new file mode 100644
index 0000000000..f114b8e258
--- /dev/null
+++ b/polaris-core/src/test/java/org/apache/polaris/core/entity/PolarisEntityCoreTest.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.entity;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.stream.Stream;
+import org.junit.jupiter.api.Named;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+public class PolarisEntityCoreTest {
+
+ static Stream<Arguments> reservedAdminEntities() {
+ return Stream.of(
+ Arguments.of(
+ Named.of(
+ "root principal",
+ new PrincipalEntity.Builder()
+ .setId(1L)
+ .setName(PolarisEntityConstants.getRootPrincipalName())
+ .build())),
+ Arguments.of(
+ Named.of(
+ "service_admin principal role",
+ new PrincipalRoleEntity.Builder()
+ .setId(2L)
+ .setName(PolarisEntityConstants.getNameOfPrincipalServiceAdminRole())
+ .build())),
+ Arguments.of(
+ Named.of(
+ "catalog_admin catalog role",
+ new CatalogRoleEntity.Builder()
+ .setId(3L)
+ .setName(PolarisEntityConstants.getNameOfCatalogAdminRole())
+ .build())));
+ }
+
+ static Stream<Arguments> ordinaryEntities() {
+ return Stream.of(
+ Arguments.of(
+ Named.of(
+ "non-root principal",
+ new PrincipalEntity.Builder().setId(4L).setName("alice").build())),
+ Arguments.of(
+ Named.of(
+ "non-admin principal role",
+ new PrincipalRoleEntity.Builder().setId(5L).setName("data_engineer").build())),
+ Arguments.of(
+ Named.of(
+ "non-admin catalog role",
+ new CatalogRoleEntity.Builder().setId(6L).setName("reader").build())));
+ }
+
+ /**
+ * The root principal must be protected alongside the admin roles: realm bootstrap identifies a
+ * bootstrapped realm by the presence of a principal named {@code root}, so dropping or renaming
+ * it breaks newly started processes for that realm.
+ */
+ @ParameterizedTest
+ @MethodSource("reservedAdminEntities")
+ void reservedAdminEntitiesCannotBeDroppedOrRenamed(PolarisEntityCore entity) {
+ assertThat(entity.cannotBeDroppedOrRenamed()).isTrue();
+ }
+
+ @ParameterizedTest
+ @MethodSource("ordinaryEntities")
+ void ordinaryEntitiesCanBeDroppedOrRenamed(PolarisEntityCore entity) {
+ assertThat(entity.cannotBeDroppedOrRenamed()).isFalse();
+ }
+}