File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
polaris-core/src/main/java/org/apache/polaris/core/auth
runtime/service/src/main/java/org/apache/polaris/service/admin Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 1818 */
1919package org .apache .polaris .core .auth ;
2020
21+ import static org .apache .polaris .core .entity .PolarisEntityConstants .getRootPrincipalName ;
2122import static org .apache .polaris .core .entity .PolarisPrivilege .CATALOG_ATTACH_POLICY ;
2223import static org .apache .polaris .core .entity .PolarisPrivilege .CATALOG_CREATE ;
2324import 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
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments