Skip to content

Commit d54a158

Browse files
committed
Authorizer: expose the required level of detail
Adds informative functions for `PolarisAuthorizer` call sites whether principal roles, catalog roles and resolved entities are required. This change allows call sites to skip certain lookups against the backend database for information that's not needed for authorizers. For example the OPA authorizer neither needs roles nor any grant information from `ResolvedPolarisEntity`. This change only adds the informative functions to `Authorizer` but does not add any optimization to the call sites.
1 parent 56e0a0a commit d54a158

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

extensions/auth/opa/impl/src/main/java/org/apache/polaris/extension/auth/opa/OpaPolarisAuthorizer.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@ public OpaPolarisAuthorizer(
9595
this.objectMapper = objectMapper;
9696
}
9797

98+
@Override
99+
public boolean requiresPrincipalRoles() {
100+
return false;
101+
}
102+
103+
@Override
104+
public boolean requiresCatalogRoles() {
105+
return false;
106+
}
107+
108+
@Override
109+
public boolean requiresResolvedEntities() {
110+
return false;
111+
}
112+
98113
/**
99114
* Authorizes a single target and secondary entity for the given principal and operation.
100115
*

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,42 @@
2828
/** Interface for invoking authorization checks. */
2929
public interface PolarisAuthorizer {
3030

31+
/**
32+
* Whether the implementation expects Polaris principal roles to be present in the {@code
33+
* activatedEntities} parameters of the {@link #authorizeOrThrow(PolarisPrincipal, Set,
34+
* PolarisAuthorizableOperation, PolarisResolvedPathWrapper, PolarisResolvedPathWrapper)}
35+
* functions.
36+
*
37+
* <p>If {@code false}, call sites may choose to not pass principal roles.
38+
*/
39+
default boolean requiresPrincipalRoles() {
40+
return true;
41+
}
42+
43+
/**
44+
* Whether the implementation expects Polaris catalog roles to be present in the {@code
45+
* activatedEntities} parameters of the {@link #authorizeOrThrow(PolarisPrincipal, Set,
46+
* PolarisAuthorizableOperation, PolarisResolvedPathWrapper, PolarisResolvedPathWrapper)}
47+
* functions.
48+
*
49+
* <p>If {@code false}, call sites may choose to not pass catalog roles.
50+
*/
51+
default boolean requiresCatalogRoles() {
52+
return true;
53+
}
54+
55+
/**
56+
* Whether the implementation expects the {@link
57+
* org.apache.polaris.core.persistence.ResolvedPolarisEntity}s in the {@link
58+
* PolarisResolvedPathWrapper} instances of the {@code target} and {@code secondary} parameters to
59+
* contain grant records information.
60+
*
61+
* <p>If {@code false}, call sites may choose to not pass grant records.
62+
*/
63+
default boolean requiresResolvedEntities() {
64+
return true;
65+
}
66+
3167
void authorizeOrThrow(
3268
@Nonnull PolarisPrincipal polarisPrincipal,
3369
@Nonnull Set<PolarisBaseEntity> activatedEntities,

0 commit comments

Comments
 (0)