Skip to content

Commit c4133f3

Browse files
fixed more refactoring comments
1 parent 017a27c commit c4133f3

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ void authorizeOrThrow(
4444
@Nonnull PolarisAuthorizableOperation authzOp,
4545
@Nullable List<PolarisResolvedPathWrapper> targets,
4646
@Nullable List<PolarisResolvedPathWrapper> secondaries);
47+
48+
void authorizeOrThrow(@Nonnull AuthenticatedPolarisPrincipal authenticatedPrincipal);
4749
}

polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizerImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.apache.polaris.core.auth;
2020

21+
import static org.apache.polaris.core.entity.PolarisEntityConstants.getRootPrincipalName;
2122
import static org.apache.polaris.core.entity.PolarisPrivilege.CATALOG_ATTACH_POLICY;
2223
import static org.apache.polaris.core.entity.PolarisPrivilege.CATALOG_CREATE;
2324
import static org.apache.polaris.core.entity.PolarisPrivilege.CATALOG_DETACH_POLICY;
@@ -602,6 +603,15 @@ public void authorizeOrThrow(
602603
}
603604
}
604605

606+
@Override
607+
public void authorizeOrThrow(@Nonnull AuthenticatedPolarisPrincipal authenticatedPrincipal) {
608+
boolean isRoot =
609+
getRootPrincipalName().equals(authenticatedPrincipal.getPrincipalEntity().getName());
610+
if (!isRoot) {
611+
throw new ForbiddenException("Only %s principal can reset credentials", authenticatedPrincipal.getPrincipalEntity().getName());
612+
}
613+
}
614+
605615
/**
606616
* Based on the required target/targetParent/secondary/secondaryParent privileges mapped from
607617
* {@code authzOp}, determines whether the caller's set of activatedGranteeIds is authorized for

runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,7 @@ private void authorizeBasicTopLevelEntityOperationOrThrow(
287287
resolutionManifest.getResolvedTopLevelEntity(topLevelEntityName, entityType);
288288

289289
if (op.equals(PolarisAuthorizableOperation.RESET_CREDENTIALS)) {
290-
boolean isRoot =
291-
getRootPrincipalName().equals(authenticatedPrincipal.getPrincipalEntity().getName());
292-
if (!isRoot) {
293-
throw new ForbiddenException("Only root principal can reset credentials");
294-
}
290+
authorizer.authorizeOrThrow(authenticatedPrincipal);
295291
LOGGER
296292
.atDebug()
297293
.addKeyValue("principalName", topLevelEntityName)

0 commit comments

Comments
 (0)