Repository navigation
[Server] Authorize the Iceberg REST catalog endpoints - #1813
Conversation
a28e6cb to
27ea214
Compare
|
FYI @iamkiayun |
f45e559 to
d9577e7
Compare
There was a problem hiding this comment.
High level LGTM
- Replaces the metastore-owner placeholder on the Iceberg REST endpoints with the shared
AuthorizeExpressionspolicies, adds per-row@ResponseAuthorizeFilteron listNamespaces/listTables, and adds an exhaustive access-control test. Well-scoped; the UC REST/Delta moves onto shared constants look behavior-preserving, and leaving updateTable/renameTable on the metastore-owner placeholder fails closed. - One question on the
getLoadCredentialPrivilegesguard removal; the rest are nits.
| if (state.dataSourceFormat() != DataSourceFormat.ICEBERG) { | ||
| return READ_ONLY; | ||
| } | ||
| UUID principalId = userRepository.findPrincipalId(); |
There was a problem hiding this comment.
Removing the principalId == null short-circuit changes two things: (1) with auth off (AllowingAuthorizer) this now vends READ_WRITE instead of READ_ONLY — intended per the new doc; (2) with a real JCasbinAuthorizer, a null principalId here would NPE (principal.toString() in authorize/authorizeAll) instead of falling back to READ_ONLY. Is principalId provably non-null once GET_TABLE has passed? If yes, a one-line note/assert would make that explicit; if not, this is a latent NPE.
There was a problem hiding this comment.
With a real JCasbinAuthorizer but a null principalId, it would fail earlier at endpoint authorization stage and never hit here.
There was a problem hiding this comment.
Adding a comment here.
| * the resolved external location) keeps the no-overlap guard running when a path resolves to no | ||
| * external location. | ||
| */ | ||
| public static final String CREATE_ICEBERG_TABLE = |
There was a problem hiding this comment.
nit: CREATE_ICEBERG_TABLE is identical to CREATE_TABLE except for the MANAGED/EXTERNAL discriminator (#location == null vs #table_type != 'EXTERNAL'). Consider factoring the shared catalog/schema tier + external-location tail so the two policies can't drift.
There was a problem hiding this comment.
CREATE_ICEBERG_TABLE will be removed in the next PR in stack once it's able to extract table_type for IRC.
| * fields ({@code id}, {@code name}), since the rows are detached once the page returns. | ||
| */ | ||
| public record IcebergTablePage(List<String> tableNames, Optional<String> nextPageToken) {} | ||
| public record IcebergTablePage(List<TableInfoDAO> tableDaos, Optional<String> nextPageToken) {} |
There was a problem hiding this comment.
nit: returning detached TableInfoDAOs (safe only for eager id/name, per the doc) leaks a persistence entity into the service and ResultFilter, and is what forces the instanceof TableInfoDAO branch in ResultFilter (L173-176). A minimal projection record (UUID id, String name) would drop both the "eager fields only" caveat and the instanceof. Non-blocking.
There was a problem hiding this comment.
In a follow up PR, I can make a minimum interface and have TableInfoDAO implements it.
00d5a0b to
6389d67
Compare
- Gate every Iceberg REST endpoint on shared `AuthorizeExpressions` policies instead of the metastore-owner placeholder:
- `config` -> `GET_CATALOG`
- `loadNamespace`/`getNamespace`/`namespaceExists`/`listNamespaces` -> `GET_SCHEMA`
- `createNamespace` -> `CREATE_SCHEMA`
- `updateNamespaceProperties` -> `UPDATE_SCHEMA`
- `dropNamespace` -> `DELETE_SCHEMA`
- `loadTable`/`tableExists`/`loadView`/`reportMetrics`/`listTables`/`loadCredentials` -> `GET_TABLE`
- `createTable` -> `CREATE_ICEBERG_TABLE`
- `dropTable` -> `DELETE_TABLE`
- (`namespaceExists`, `updateNamespaceProperties`, `dropNamespace`, and `loadCredentials` are newer endpoints on the Iceberg surface, authorized here alongside the rest.)
- Add `GET_CATALOG`, `GET_SCHEMA`, `CREATE_SCHEMA`, `CREATE_SCHEMA_WITH_STORAGE_ROOT`, `UPDATE_SCHEMA`, `DELETE_SCHEMA`, and `CREATE_ICEBERG_TABLE` to `AuthorizeExpressions`, and filter `listNamespaces`/`listTables` per row with `@ResponseAuthorizeFilter`.
- Move existing UC REST inline expressions onto the shared constants (behavior-preserving):
- `CatalogService` get/list -> `GET_CATALOG` (dropping the private `LIST_AND_GET_AUTH_EXPRESSION`), and the `DeltaApiService` `config` expression likewise.
- `SchemaService`: `getSchema`/`listSchemas` -> `GET_SCHEMA`, `createSchema` -> `CREATE_SCHEMA_WITH_STORAGE_ROOT`, `updateSchema` -> `UPDATE_SCHEMA`, `deleteSchema` -> `DELETE_SCHEMA`.
- Return raw `TableInfoDAO`s from the `listIcebergTables` page and teach `ResultFilter` to resolve a `TABLE` id from either the DAO or a `TableInfo`, so `listTables` filters per row without re-loading each table.
- Scope the credentials `loadTable`/`loadCredentials` vend in `getLoadCredentialPrivileges` by table `OWNER`/`SELECT`+`MODIFY`, dropping the `principalId == null` short-circuit.
- Leave `updateTable` and `renameTable` on the metastore-owner placeholder; both need the body-derived `AuthorizeValueExtractor` deferred to the next branch:
- `updateTable`: one endpoint covers a plain commit (`UPDATE_TABLE`) and a staged-create commit (create authorization plus a check that the write location matches a staging table the caller can access), selected by a request-body condition a declarative expression cannot key here.
- `renameTable`: the source/destination are structured `TableIdentifier`s whose full identity spans the URL `{catalog}` and the body, which a scalar field key cannot compose into a resolvable name.
- Add `SdkIcebergRestCatalogAccessControlTest` (a per-user `IcebergRestClient` plus Iceberg error-assert helpers in `TestUtils`) exercising every authorized endpoint, with metastore-admin-denied cases on the `dropNamespace`/`updateNamespaceProperties` mutations.
Signed-off-by: Yi Li <[email protected]>
Signed-off-by: Yi Li <[email protected]>
6389d67 to
67897a5
Compare
Resolves the conflicts with unitycatalog#1813, which authorizes the Iceberg listings by filtering them per schema and per table. Both sides now apply: each page the repository reads is filtered before its entries are answered, and the token still comes from the last row read, so a page can hold fewer than pageSize, or none, while more remain. IcebergTablePage takes unitycatalog#1813's shape (the DAOs, so the filter can resolve each table by id) with this branch's maxResults. The parent-namespace branch returns early, so it calls the filter on an empty list: @ResponseAuthorizeFilter rejects a response that never ran it. Co-authored-by: Isaac <[email protected]> Signed-off-by: Noritaka Sekiyama <[email protected]>
After the merge with unitycatalog#1813 a paged listing filters each page on its own, so a page can come back empty while its token leads on. Follow the token one entry per page as a restricted principal and assert the result is the unpaged filtered listing. Neither side's tests covered the two together. Co-authored-by: Isaac <[email protected]> Signed-off-by: Noritaka Sekiyama <[email protected]>
🥞 Stacked PR
Use this link to review incremental changes.
PR Checklist
docsis updatedDescription of changes
AuthorizeExpressionspolicies instead of the metastore-owner placeholder:config->GET_CATALOGloadNamespace/getNamespace/namespaceExists/listNamespaces->GET_SCHEMAcreateNamespace->CREATE_SCHEMAupdateNamespaceProperties->UPDATE_SCHEMAdropNamespace->DELETE_SCHEMAloadTable/tableExists/loadView/reportMetrics/listTables/loadCredentials->GET_TABLEcreateTable->CREATE_ICEBERG_TABLEdropTable->DELETE_TABLEnamespaceExists,updateNamespaceProperties,dropNamespace, andloadCredentialsare newer endpoints on the Iceberg surface, authorized here alongside the rest.)GET_CATALOG,GET_SCHEMA,CREATE_SCHEMA,CREATE_SCHEMA_WITH_STORAGE_ROOT,UPDATE_SCHEMA,DELETE_SCHEMA, andCREATE_ICEBERG_TABLEtoAuthorizeExpressions, and filterlistNamespaces/listTablesper row with@ResponseAuthorizeFilter.CatalogServiceget/list ->GET_CATALOG(dropping the privateLIST_AND_GET_AUTH_EXPRESSION), and theDeltaApiServiceconfigexpression likewise.SchemaService:getSchema/listSchemas->GET_SCHEMA,createSchema->CREATE_SCHEMA_WITH_STORAGE_ROOT,updateSchema->UPDATE_SCHEMA,deleteSchema->DELETE_SCHEMA.TableInfoDAOs from thelistIcebergTablespage and teachResultFilterto resolve aTABLEid from either the DAO or aTableInfo, solistTablesfilters per row without re-loading each table.loadTable/loadCredentialsvend ingetLoadCredentialPrivilegesby tableOWNER/SELECT+MODIFY, dropping theprincipalId == nullshort-circuit.updateTableandrenameTableon the metastore-owner placeholder; both need the body-derivedAuthorizeValueExtractordeferred to the next branch:updateTable: one endpoint covers a plain commit (UPDATE_TABLE) and a staged-create commit (create authorization plus a check that the write location matches a staging table the caller can access), selected by a request-body condition a declarative expression cannot key here.renameTable: the source/destination are structuredTableIdentifiers whose full identity spans the URL{catalog}and the body, which a scalar field key cannot compose into a resolvable name.SdkIcebergRestCatalogAccessControlTest(a per-userIcebergRestClientplus Iceberg error-assert helpers inTestUtils) exercising every authorized endpoint, with metastore-admin-denied cases on thedropNamespace/updateNamespacePropertiesmutations.