Repository navigation
[Server] Add MANAGE permission #2088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
24b15a3
0c7280c
425ae3e
bd76b57
aba47cf
ccef782
a6378f5
f4832de
7a014a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,61 +25,62 @@ private AuthorizeExpressions() {} | |
|
|
||
| /** | ||
| * Authorization policy for reading table metadata and filtering table listings. Metastore admin | ||
| * and catalog owner pass unconditionally; schema owner passes with catalog {@code USE_CATALOG}; | ||
| * regular callers need {@code USE_SCHEMA} + {@code USE_CATALOG} plus {@code OWNER} or {@code | ||
| * SELECT} on the table. With strict privilege checks disabled, {@code MODIFY} also permits | ||
| * metadata access. {@code READ_METADATA} at metastore or catalog scope needs no usage grants; | ||
| * schema scope needs {@code USE_CATALOG}, and table scope needs both usage grants. | ||
| * and catalog OWNER/MANAGE pass unconditionally; schema OWNER/MANAGE needs catalog {@code | ||
| * USE_CATALOG}; other callers need {@code USE_SCHEMA} + {@code USE_CATALOG} plus {@code OWNER}, | ||
| * {@code MANAGE}, or {@code SELECT} on the table. With strict privilege checks disabled, {@code | ||
| * MODIFY} also permits metadata access. {@code READ_METADATA} at metastore or catalog scope needs | ||
| * no usage grants; schema scope needs {@code USE_CATALOG}, and table scope needs both usage | ||
| * grants. | ||
|
Comment on lines
+28
to
+33
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the change in this comment basically just talking about also including MANAGE in some checks? based on the code changes, it just looks like we're adding MANAGE to authorization for some
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The policy change here is adding |
||
| */ | ||
| // TODO(#2024): Remove the MODIFY fallback when the migration flag is removed. | ||
| public static final String GET_TABLE = | ||
| """ | ||
| #authorizeAny(#principal, #metastore, OWNER, READ_METADATA) || | ||
| #authorizeAny(#principal, #catalog, OWNER, READ_METADATA) || | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE, READ_METADATA) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorizeAny(#principal, #schema, OWNER, READ_METADATA)) || | ||
| #authorizeAny(#principal, #schema, OWNER, MANAGE, READ_METADATA)) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorize(#principal, #schema, USE_SCHEMA) && | ||
| (#authorizeAny(#principal, #table, OWNER, SELECT, READ_METADATA) || | ||
| (#authorizeAny(#principal, #table, OWNER, MANAGE, SELECT, READ_METADATA) || | ||
| (!#strict_privilege_checks && #authorize(#principal, #table, MODIFY)))) | ||
| """; | ||
|
|
||
| /** | ||
| * Catalog-level read access: metastore admin, or {@code OWNER}/{@code USE_CATALOG} on the | ||
| * catalog, or {@code READ_METADATA} on the metastore or catalog. Shared by the catalog get/list | ||
| * endpoints and the Delta/Iceberg config endpoints. | ||
| * Catalog-level read access: metastore admin, or {@code OWNER}/{@code MANAGE}/{@code USE_CATALOG} | ||
| * on the catalog, or {@code READ_METADATA} on the metastore or catalog. Shared by the catalog | ||
| * get/list endpoints and the Delta/Iceberg config endpoints. | ||
| */ | ||
| public static final String GET_CATALOG = | ||
| """ | ||
| #authorizeAny(#principal, #metastore, OWNER, READ_METADATA) || | ||
| #authorizeAny(#principal, #catalog, OWNER, USE_CATALOG, READ_METADATA) | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE, USE_CATALOG, READ_METADATA) | ||
| """; | ||
|
|
||
| /** | ||
| * Schema-level read access: metastore admin, catalog {@code OWNER}, or schema {@code | ||
| * OWNER}/{@code USE_SCHEMA} with catalog {@code USE_CATALOG}. Used as the get-schema gate and the | ||
| * list-schemas/namespaces response filter (listing and reading grant the same access). {@code | ||
| * READ_METADATA} on the metastore or catalog needs no usage grants; on the schema it needs {@code | ||
| * USE_CATALOG}. | ||
| * Schema-level read access: metastore admin, catalog {@code OWNER}/{@code MANAGE}, or schema | ||
| * {@code OWNER}/{@code MANAGE}/{@code USE_SCHEMA} with catalog {@code USE_CATALOG}. Used as the | ||
| * get-schema gate and the list-schemas/namespaces response filter (listing and reading grant the | ||
| * same access). {@code READ_METADATA} on the metastore or catalog needs no usage grants; on the | ||
| * schema it needs {@code USE_CATALOG}. | ||
| */ | ||
| public static final String GET_SCHEMA = | ||
| """ | ||
| #authorizeAny(#principal, #metastore, OWNER, READ_METADATA) || | ||
| #authorizeAny(#principal, #catalog, OWNER, READ_METADATA) || | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE, READ_METADATA) || | ||
| (#authorizeAny(#principal, #catalog, USE_CATALOG) && | ||
| #authorizeAny(#principal, #schema, OWNER, USE_SCHEMA, READ_METADATA)) | ||
| #authorizeAny(#principal, #schema, OWNER, MANAGE, USE_SCHEMA, READ_METADATA)) | ||
| """; | ||
|
|
||
| /** Function metadata access, shared by get and list filtering. */ | ||
| public static final String GET_FUNCTION = | ||
| """ | ||
| #authorizeAny(#principal, #metastore, OWNER, READ_METADATA) || | ||
| #authorizeAny(#principal, #catalog, OWNER, READ_METADATA) || | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE, READ_METADATA) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorizeAny(#principal, #schema, OWNER, READ_METADATA)) || | ||
| #authorizeAny(#principal, #schema, OWNER, MANAGE, READ_METADATA)) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorize(#principal, #schema, USE_SCHEMA) && | ||
| #authorizeAny(#principal, #function, OWNER, EXECUTE, READ_METADATA)) | ||
| #authorizeAny(#principal, #function, OWNER, MANAGE, EXECUTE, READ_METADATA)) | ||
| """; | ||
|
|
||
| /** | ||
|
|
@@ -110,16 +111,17 @@ private AuthorizeExpressions() {} | |
| """; | ||
|
|
||
| /** | ||
| * Schema-level mutation policy (update or delete a schema): catalog {@code OWNER}, or {@code | ||
| * USE_CATALOG} + schema {@code OWNER}. Metastore admin alone is intentionally not sufficient. | ||
| * Shared by the UC REST {@code updateSchema}/{@code deleteSchema} and the Iceberg REST {@code | ||
| * updateNamespaceProperties}/{@code dropNamespace} endpoints (updating and dropping a schema | ||
| * require the same privilege). | ||
| * Schema-level mutation policy: catalog OWNER/MANAGE, or {@code USE_CATALOG} + schema | ||
| * OWNER/MANAGE. Metastore admin alone is intentionally not sufficient for ordinary metadata | ||
| * updates or deletion. Shared by the UC REST {@code updateSchema}/{@code deleteSchema} and the | ||
| * Iceberg REST {@code updateNamespaceProperties}/{@code dropNamespace} endpoints (updating and | ||
| * dropping a schema require the same privilege). Schema grant updates also reuse this policy. | ||
| */ | ||
| public static final String UPDATE_SCHEMA = | ||
| """ | ||
| #authorize(#principal, #catalog, OWNER) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && #authorize(#principal, #schema, OWNER)) | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorizeAny(#principal, #schema, OWNER, MANAGE)) | ||
|
Comment on lines
+123
to
+124
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it doesnt fit on one line?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be 106 characters on one line. Checkstyle limits lines to 100, so I kept the break. |
||
| """; | ||
|
|
||
| /** Deleting a schema requires the same privilege as {@link #UPDATE_SCHEMA}. */ | ||
|
|
@@ -193,15 +195,53 @@ private AuthorizeExpressions() {} | |
| /** | ||
| * Authorization policy for deleting a table, shared by the UC REST, UC Delta API, and Iceberg | ||
| * REST delete endpoints. Metastore admin alone is intentionally not sufficient -- the caller must | ||
| * hold {@code OWNER} somewhere in the catalog / schema / table hierarchy. | ||
| * hold OWNER/MANAGE in the catalog / schema / table hierarchy, with usage above that scope. Table | ||
| * grant updates also reuse this policy. | ||
| */ | ||
| public static final String DELETE_TABLE = | ||
| """ | ||
| #authorize(#principal, #catalog, OWNER) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && #authorize(#principal, #schema, OWNER)) || | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorizeAny(#principal, #schema, OWNER, MANAGE)) || | ||
|
Comment on lines
+204
to
+205
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it cant be on one line?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This branch would be 109 characters on one line, including |
||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorize(#principal, #schema, USE_SCHEMA) && | ||
| #authorizeAny(#principal, #table, OWNER, MANAGE)) | ||
|
Comment on lines
+206
to
+208
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh i see its cascading... like this anyOf(OWNER, MANAGE) moves down from catalog to table.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The three branches check |
||
| """; | ||
|
|
||
| /** Function deletion and grant changes, with usage required above the management scope. */ | ||
| public static final String UPDATE_FUNCTION = | ||
| """ | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorizeAny(#principal, #schema, OWNER, MANAGE)) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorize(#principal, #schema, USE_SCHEMA) && | ||
| #authorizeAny(#principal, #function, OWNER, MANAGE)) | ||
| """; | ||
|
|
||
| /** Volume metadata updates, deletion, and grant changes. File access has separate checks. */ | ||
| public static final String UPDATE_VOLUME = | ||
|
Comment on lines
+212
to
+223
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to introduce UPDATE_FUNCTION, UPDATE_VOLUME, and UPDATE_REGISTERED_MODEL? its nice but im just wondering.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Volumes and models reuse these checks across updates and deletes. Models also use the same check for version metadata.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [AI Assisted] UPDATE_FUNCTION has two callers in this PR, not one: FunctionService.deleteFunction and PermissionService.updateFunctionAuthorization. Because it also gates grants, a later change to delete semantics would silently change who can grant. Would MANAGE_FUNCTION read more accurately, with the same for the volume, model, and table constants? At minimum, the Javadoc should say the constant also gates grants.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the comments to say these policies also control grant changes. I kept the existing constant names. |
||
| """ | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorizeAny(#principal, #schema, OWNER, MANAGE)) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorize(#principal, #schema, USE_SCHEMA) && | ||
| #authorizeAny(#principal, #volume, OWNER, MANAGE)) | ||
| """; | ||
|
|
||
| /** | ||
| * Model metadata updates, deletion, and grant changes. Publication and file access have separate | ||
| * checks. | ||
| */ | ||
| public static final String UPDATE_REGISTERED_MODEL = | ||
| """ | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorizeAny(#principal, #schema, OWNER, MANAGE)) || | ||
| (#authorize(#principal, #catalog, USE_CATALOG) && | ||
| #authorize(#principal, #schema, USE_SCHEMA) && | ||
| #authorize(#principal, #table, OWNER)) | ||
| #authorizeAny(#principal, #registered_model, OWNER, MANAGE)) | ||
| """; | ||
|
|
||
| /** | ||
|
|
@@ -214,8 +254,8 @@ private AuthorizeExpressions() {} | |
| + """ | ||
| ) && | ||
| (#authorizeAny(#principal, #catalog, OWNER, USE_CATALOG) && | ||
| (#authorize(#principal, #schema, OWNER) || | ||
| #authorizeAll(#principal, #schema, USE_SCHEMA, CREATE_TABLE))) | ||
| #authorizeAny(#principal, #schema, OWNER, USE_SCHEMA) && | ||
| #authorizeAny(#principal, #schema, OWNER, CREATE_TABLE)) | ||
| """; | ||
|
|
||
| /** | ||
|
|
@@ -251,8 +291,8 @@ private AuthorizeExpressions() {} | |
| /** | ||
| * Iceberg credentials require the read permissions in {@link #VEND_TABLE_CREDENTIAL}. With strict | ||
| * checks disabled, metastore or catalog ownership, schema ownership with {@code USE_CATALOG}, or | ||
| * {@code MODIFY} with both usage grants also permits credentials. {@code READ_METADATA} alone | ||
| * does not permit credentials. | ||
| * {@code MODIFY} with both usage grants also permits credentials. {@code READ_METADATA} or {@code | ||
| * MANAGE} alone does not permit credentials. | ||
| */ | ||
| // TODO(#2024): Reuse VEND_TABLE_CREDENTIAL with a fixed READ operation after removing the flag. | ||
| public static final String VEND_ICEBERG_TABLE_CREDENTIAL = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,19 +114,22 @@ public HttpResponse getCatalog( | |
| @Patch("/{name}") | ||
| @AuthorizeExpression( | ||
| """ | ||
| #authorize(#principal, #catalog, OWNER) | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE) && | ||
| (#new_name == null || #authorize(#principal, #catalog, OWNER) || | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [AI Assisted] Could we add owner-path cases here? The new #new_name branches in updateCatalog and SchemaService.updateSchema have no test where the owner renames; the rename scenario only covers managers. Cases: a catalog owner renames with no create grant; a schema owner with USE CATALOG renames; a schema owner without USE CATALOG is denied.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added all three cases. The tests also check that renaming keeps the same object ID. |
||
| #authorizeAny(#principal, #metastore, OWNER, CREATE_CATALOG)) | ||
| """) | ||
| @AuthorizeResourceKey(METASTORE) | ||
| public HttpResponse updateCatalog( | ||
| @Param("name") @AuthorizeResourceKey(CATALOG) String name, UpdateCatalog updateCatalog) { | ||
| @Param("name") @AuthorizeResourceKey(CATALOG) String name, | ||
| @AuthorizeKey(key = "new_name") UpdateCatalog updateCatalog) { | ||
|
Comment on lines
+118
to
+124
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what? what is this new name thing?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh? you say its existing but we're adding it here.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Before this PR, We need it because a manager can edit a comment with
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok im guessing rename was just not wired into these permissions rules... |
||
| return HttpResponse.ofJson(catalogRepository.updateCatalog(name, updateCatalog)); | ||
| } | ||
|
|
||
| @Delete("/{name}") | ||
| @AuthorizeExpression( | ||
| """ | ||
| #authorize(#principal, #metastore, OWNER) || | ||
| #authorize(#principal, #catalog, OWNER) | ||
| #authorizeAny(#principal, #catalog, OWNER, MANAGE) | ||
| """) | ||
| @AuthorizeResourceKey(METASTORE) | ||
| public HttpResponse deleteCatalog( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[AI Assisted] Could we add these points to this section? (1) With strict-privilege-checks=false, MANAGE grants are still validated, so MANAGE on the metastore is rejected. (2) Renaming a catalog, schema, table, volume, or model with MANAGE needs the matching create privilege in both modes; the migration list shows volume and model rename as strict-only. (3) nit: the note that existing MANAGE grants become active after upgrade (line 264) does not apply, since MANAGE has not shipped in a release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. The docs now explain that MANAGE validation and manager rename checks apply in both modes. I clarified the owner rename entries and removed the upgrade note.