Repository navigation
[Server] Add BROWSE permission - #2087
Conversation
|
/review |
3216e41 to
2a4fc31
Compare
9dafee8 to
8504f42
Compare
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Thanks for the follow-up commit; the external location descriptions, the auth-disabled test, and the unused VolumeRepository parameter all look good. A few remaining comments inline.
| evaluator, | ||
| principal, | ||
| expression, | ||
| Boolean.parseBoolean(ctx.queryParam("include_browse")) |
There was a problem hiding this comment.
[AI Assisted] The flag is parsed here from the raw query string, while every handler also declares @Param("include_browse") Optional<Boolean> includeBrowse and never reads it. Two places parsing the same flag can drift. It fails closed today, so this is not a correctness issue, but it is confusing for the next reader. Can we make the decorator the only reader and drop the unused handler params? If they are kept on purpose, a short comment saying why would help.
There was a problem hiding this comment.
kept the params so armeria rejects invalid values. added a comment explaining why. the decorator now uses armeria’s conversion too, with tests for 1 and invalid values.
| } | ||
|
|
||
| /** Returns full or BROWSE-only metadata, or denies access to a GET result. */ | ||
| protected <T> T applyResponseFilter(T item, UnaryOperator<T> browseOnly) { |
There was a problem hiding this comment.
[AI Assisted] With @ResponseAuthorizeFilter on the GET handlers, authorization for every GET (not only include_browse=true) now runs after the repository read instead of in the decorator before the handler. A denied caller still gets PERMISSION_DENIED, but the handler now does the full load for callers it will reject, and errors raised by the handler now come before the auth check. Can we call this out in the PR description? Alternatively, keep the request-time check when include_browse is not set and defer only for the BROWSE fallback.
There was a problem hiding this comment.
yep, added this to the pr description. it also applies when include_browse is false or omitted.
There was a problem hiding this comment.
[AI Assisted] Thanks for documenting it, and the ID check is a good addition. I still think the ordering should be restored for callers who don't opt in: when include_browse is unset, can ResultFilterAction.beforeRequest evaluate the ordinary expression right away (the resource IDs are already resolved there) and only defer to filterResult for the BROWSE fallback? That keeps the enforcement boundary where it was for every existing caller. The bot's Blocker1 asks for the same thing.
There was a problem hiding this comment.
@yili-db fixed. ordinary GETs now check permissions before the handler runs when include_browse is false or unset. kept the returned object ID check and added a regression test to confirm the handler never runs for those denied requests.
| @EnumSource( | ||
| value = TableType.class, | ||
| names = {"MANAGED", "EXTERNAL", "VIEW"}) | ||
| void tableDiscoveryKeepsColumnFieldsAndOmitsStorageAndDefinitions(TableType tableType) |
There was a problem hiding this comment.
[AI Assisted] Nice that the converter is an allowlist, so a new TableInfo or ColumnInfo field stays hidden by default. But this test builds its input from hand-written JSON, so adding a field to the spec still passes and nobody has to decide whether BROWSE callers should see it. Can we add a check that populates every model property and asserts the exact browse-visible field set? Then a new field fails the test until someone classifies it. Same for FunctionInfo, where input_params and return_params are copied as whole objects, so a new nested parameter field would show up in browse responses automatically.
There was a problem hiding this comment.
done, extended the existing tests to cover every table, column, and function field, including nested parameters. new fields now fail the tests until we decide how browse should handle them.
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2091/files) to review incremental changes. - [**stack/permission-enums**](#2091) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2091/files)] ← _this PR_ - [stack/feat/browse-privilege](#2087) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2087/files/9f6b2ba7bcb2d8179b0dea15094d180602f95723..8504f42cac04ea8cac31e3b86807530ba0144057)] - [stack/feat/create-model-version-privilege](#2085) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2085/files/9f6b2ba7bcb2d8179b0dea15094d180602f95723..8575d777673066ca569002d40f6eab19631c936f)] - [stack/feat/manage-privilege](#2088) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2088/files/9f6b2ba7bcb2d8179b0dea15094d180602f95723..b41a2d34cfad7af957d8fd9ebd5446d0a42cd74b)] - [stack/feat/read-metadata-privilege](#2086) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2086/files/9f6b2ba7bcb2d8179b0dea15094d180602f95723..dd162f6987b22700fca3b18ac5105cc261e19e6a)] - [stack/feat/write-volume-privilege](#2084) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2084/files/9f6b2ba7bcb2d8179b0dea15094d180602f95723..7112a998365fc1d322bae3f26f6ba00d9fefc39e)] --------- **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [ ] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** Add `BROWSE`, `MANAGE`, `WRITE VOLUME`, `CREATE MODEL VERSION`, and `READ METADATA` to the API and server enums. Validate where each permission can be granted. The child PRs add the authorization checks for each permission. **Before** With authorization enabled, the owner of `main.public.sales` tries to grant an existing user metadata access: ```http PATCH /api/2.1/unity-catalog/permissions/table/main.public.sales Content-Type: application/json {"changes": [{"principal": "[email protected]", "add": ["READ METADATA"]}]} ``` The API rejects the request because `READ METADATA` is not a recognized privilege. **After** The owner repeats the same request: ```http PATCH /api/2.1/unity-catalog/permissions/table/main.public.sales Content-Type: application/json {"changes": [{"principal": "[email protected]", "add": ["READ METADATA"]}]} ``` The API accepts and saves the grant. It also accepts `BROWSE`, `MANAGE`, `WRITE VOLUME`, and `CREATE MODEL VERSION` on their supported object types. For example, `BROWSE` is valid on a catalog or external location and is rejected on a table. The child PRs add the authorization checks that make these grants affect metadata reads, grant changes, and credential requests. This is the shared parent for #2084, #2085, #2086, #2087, and #2088. Validation: 21 focused enum and permission tests passed on JDK 17. API generation, Java formatting, and server Compile/Test Checkstyle passed. Signed-off-by: Timothy Wang <[email protected]>
|
/review |
1 similar comment
|
/review |
|
/review |
804ec92 to
df95074
Compare
|
/review |
|
[AI Assisted] Nice resolution of the A few small things:
|
df95074 to
265958b
Compare
Signed-off-by: Timothy Wang <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
Reject GET results when their ID differs from the ID resolved for authorization. Signed-off-by: Timothy Wang <[email protected]>
Keep the next authorized item when a BROWSE permission check or projection fails. Signed-off-by: Timothy Wang <[email protected]>
Move the UI type refresh to a follow-up PR. The UI does not use the new BROWSE fields yet. Signed-off-by: Timothy Wang <[email protected]>
Keep SDK calls explicit and check BROWSE list permission reuse. Update batching assertions for the READ METADATA rule. Signed-off-by: Timothy Wang <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
Reject denied single-object requests before the handler runs when BROWSE is disabled. Keep response filtering and returned-object ID validation. Signed-off-by: Timothy Wang <[email protected]>
265958b to
310318c
Compare
|
/review |
|
nothing in https://github.com/unitycatalog/unitycatalog/pull/2087/checks?check_run_id=128110148727 worth expanding the PR for. |
|
This needs @tdas approval for |
|
/review |
Signed-off-by: Timothy Wang <[email protected]>
|
/review |
Signed-off-by: Timothy Wang <[email protected]>
#### Which Delta project/connector is this regarding? - [ ] Spark - [ ] Standalone - [x] Flink - [ ] Kernel - [ ] Other (fill in here) ## Description Building Delta against Unity Catalog after unitycatalog/unitycatalog#2087 fails before tests run. The generated Java client adds an `includeBrowse` argument to its get/list methods. For example, `SchemasApi.listSchemas(String, Integer, String)` now requires a fourth `Boolean` argument. The Flink connector still calls the old methods. Pass `false` for the new argument in the four Flink calls. This keeps the previous behavior and avoids requesting discovery-only metadata. Move the pinned UC revision from `6e99222` to `a9c956e`, the merge commit for the API change, so the default build uses the matching client. Update the seven Spark test calls and the Scala quickstart call that also use these methods and share the pin. ## How was this patch tested? Built and locally published the UC client and Hadoop artifacts from both exact revisions. With the original Delta source, `flink/compile` passes against `0.8.0-SNAPSHOT-6e99222` and fails against `0.8.0-SNAPSHOT-a9c956e` with all four argument-count errors. Added a WireMock regression test that calls all four Flink methods and checks that each HTTP request sends `include_browse=false`. With this patch and UC `0.8.0-SNAPSHOT-a9c956e`, all 10 focused tests pass: ```sh build/sbt -DunityCatalogVersion=0.8.0-SNAPSHOT-a9c956e \ 'flink/testOnly io.delta.flink.table.UnityCatalogTest io.delta.flink.sink.sql.FlinkUnityCatalogTest' ``` Java format checks pass: ```sh build/sbt -DunityCatalogVersion=0.8.0-SNAPSHOT-a9c956e \ flink/Compile/javafmtCheck flink/Test/javafmtCheck sparkUnityCatalog/Test/javafmtCheck ``` The seven changed Spark Java test files also compile against the new UC client in a targeted `javac` check with cached dependencies. The full Spark integration suite and the Scala quickstart were not run. ## Does this PR introduce _any_ user-facing changes? No. This restores compilation against the updated UC Java client and keeps the existing metadata behavior. Signed-off-by: Timothy Wang <[email protected]>
🥞 Stacked PR
Use this link to review incremental changes.
PR Checklist
docsis updatedDescription of changes
This PR lets users discover catalog objects before they have permission to use them. For example, Alice can inspect a sales table's owner and columns before requesting access to its rows.
A catalog
BROWSEgrant covers the catalog and its contents withoutUSE CATALOGorUSE SCHEMA.BROWSEon an external location covers only that location.By default, get and list requests use only the usual read permissions. Add
include_browse=trueto also allow discovery throughBROWSE.The owner of
maingrants AliceBROWSE:Alice can then request the table's metadata:
With the usual read permissions, Alice gets full metadata. With only
BROWSE, this request returns discovery fields markedbrowse_only=true. With neither, a GET returnsPERMISSION_DENIEDand a list leaves the object out. Data access, credentials, and changes still require their existing permissions.Discovery retains catalog and schema properties and storage paths, plus model and volume storage paths. It hides table storage details, function code, and external location credential references.
A shared response filter checks permissions, selects fields, and verifies object IDs. Single-object requests with
include_browsefalse or missing keep the early permission check. Java callers must addincludeBrowseand recompile. Passfalseto keep existing behavior.Validation: 67 focused H2 tests, formatting, and Checkstyle passed.