You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org> on 2026/10/07 03:59:25 UTC

[PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

tanishqgandhi1908 opened a new pull request, #8890:
URL: https://github.com/apache/texera/pull/8890

   ### What changes were proposed in this PR?
   
   ResourceAccess.grant and revoke only checked that the caller has write access, so a WRITE collaborator could downgrade the owner to READ or remove the owner's access row. The owner then got read-only controls on their own dataset or model, or lost it from their list and search.
   
   Both now refuse with 403 when the target user is the owner, with the message workflows already use ("You cannot modify the owner's permissions!"). Datasets and models share this code, so both are fixed.
   
   Before: the collaborator shares the dataset with the owner as READ, and the owner loses the Settings tab, delete button and upload panel:
   
   <img width="1440" height="900" alt="before-2-collab-shares-owner-read" src="https://github.com/user-attachments/assets/73d09dde-0f5d-47ed-87a5-28de28f47869" />
   
   <img width="1440" height="900" alt="before-4-owner-after" src="https://github.com/user-attachments/assets/e6c17268-d3dd-48fe-b181-d473051b14d9" />
   After: the same share is refused, and the owner's page is unchanged:
   
   <img width="1440" height="900" alt="after-1-share-refused" src="https://github.com/user-attachments/assets/1989748e-e285-4d9d-b46b-2608817e88bb" />
   
   <img width="1440" height="900" alt="after-2-owner-keeps-access" src="https://github.com/user-attachments/assets/b5df49da-fc62-4366-bfa1-d03597a450fc" />
   
   
   ### Any related issues, documentation, discussions?
   Closes #8889
   
   
   ### How was this PR tested?
   Added two cases each to DatasetAccessResourceSpec and ModelAccessResourceSpec: a WRITE grantee trying to change or revoke the owner's access gets 403, and the owner's privilege stays WRITE. They fail without the fix.
   
   sbt "FileService/testOnly *DatasetAccessResourceSpec *ModelAccessResourceSpec"
   # Tests: succeeded 73, failed 0
   
   Also checked against a local stack: sharing a dataset with its owner's email as READ is refused in the UI, and DELETE /api/access/dataset/revoke/{did}/{ownerEmail} returns 403.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   Generated-by: Claude Code (Claude Opus 5.5)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on PR #8890:
URL: https://github.com/apache/texera/pull/8890#issuecomment-6117942936

   @xuang7 or @mengw15, Can you please review the PR when possible? Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on PR #8890:
URL: https://github.com/apache/texera/pull/8890#issuecomment-6423118246

   > Thanks for the update.
   > 
   > * `/hub/user-access` returns only the uids found in the access table, and the frontend's `entryLink` uses that list to choose between the private page and the hub page. An owner whose row was already removed is therefore still sent to the hub page. Including the owner's uid there or having `entryLink` also check `entry.isOwner`, would close it.
   > * `fetchDashboardVersionedResourcesByIds` still joins every user's access row so a non-owner can be shown another user's privilege including the owner's WRITE.
   > * Workflows still read privilege from the row alone.
   > 
   > Could these be fixed here or tracked as issues with the description narrowed to match?
   
   Thanks! Have fixed the current points and updated the description
   
   1. entryLink now also treats the entry’s owner (ownerId) as able to reach the private page.
   2. fetchDashboardVersionedResourcesByIds now limits the access join to the viewer, as search does, so a card only carries the viewer’s own privilege.
   3. Workflows: their sharing already refuses to change or remove the owner’s row, so the app can’t damage it. Moving their read paths to the same owner rule touches workflow search and access code, so I have filed #9150 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4274201796


##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -257,6 +257,7 @@ object ResourceAccess {
       throw new BadRequestException(s"No registered user with email $email")
     }
     val granteeUid = grantee.getUid
+    requireNotOwner(ctx, resource, id, granteeUid)

Review Comment:
   One thing to consider: owners who were already downgraded or removed before this fix can no longer be repaired. Is this problem an existing case in our deployments or local development environments? If that's the case, can you add a one-time SQL migration script that restores WRITE for every dataset and model? The reason is owners who were already damaged are stuck forever even after the fix.



##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -311,6 +314,16 @@ object ResourceAccess {
       )
     }
 
+  private def requireNotOwner[R <: Record, A <: Record](

Review Comment:
   Can we just treat the owner as WRITE in those read spots, so a bad row can never affect the owner and old bad rows would heal without a migration instead? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4343402322


##########
amber/src/main/scala/org/apache/texera/web/resource/dashboard/VersionedResourceTables.scala:
##########
@@ -90,13 +90,16 @@ trait VersionedResourceTables[Rec <: Record, P] extends BaseEntityTable with Laz
       uid: Integer
   ): Option[(Integer, DashboardClickableFileEntry)] = {
     val resource = pojo(record)
+    val isOwner = ownerUidOf(resource) == uid
     repositorySize(resource).map { size =>
       idOf(resource) -> entry(
         resource,
         record.into(USER).into(classOf[User]).getEmail,
-        Option(record.get(access.privilegeColumn, classOf[PrivilegeEnum]))
-          .getOrElse(PrivilegeEnum.NONE),
-        ownerUidOf(resource) == uid,
+        if (isOwner) PrivilegeEnum.WRITE
+        else
+          Option(record.get(access.privilegeColumn, classOf[PrivilegeEnum]))
+            .getOrElse(PrivilegeEnum.NONE),

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4343400874


##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -286,6 +292,7 @@ object ResourceAccess {
   ): Response = {
     requireWriteAccess(ctx, resource, id, requesterUid)
     val granteeUid = new UserDao(ctx.configuration()).fetchOneByEmail(email).getUid

Review Comment:
   This is exactly what #8384 (by @gupta-sahil01) fixes: it makes revoke reuse the same email check as grant, so both return 400. I have left it out here to avoid overlapping with that PR.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on PR #8890:
URL: https://github.com/apache/texera/pull/8890#issuecomment-6181555304

   > Can you address the comments? Also,
   > 
   > 1. Can you add more test cases to make the code coverage 100%?
   > 2. Can you check if computing unit also has a similar issue?
   
   Thanks for the review! Addressed in 1019982c7:
   
   Coverage: Codecov only counts common/resource’s own tests for this code, so I added ResourceAccessSpec there, plus tests in the search and computing-unit specs. They all fail without the change.
   Computing units had the same issue. The owner’s access can no longer be changed, the unit info treats the owner as WRITE, and the access list hides a leftover owner row.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #8890:
URL: https://github.com/apache/texera/pull/8890#issuecomment-6030619435

   <!-- texera-reviewer-suggestion -->
   ### Automated Reviewer Suggestions
   
   Based on the `git blame` history of the changed files, we recommend the following reviewers:
   
   - No candidates found from `git blame` history.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4277725414


##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -257,6 +257,7 @@ object ResourceAccess {
       throw new BadRequestException(s"No registered user with email $email")
     }
     val granteeUid = grantee.getUid
+    requireNotOwner(ctx, resource, id, granteeUid)

Review Comment:
   Fixed with checking write access instead of migration script



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4343398423


##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -69,32 +69,34 @@ object ResourceAccess {
     ).flatMap(record => Option(record.value1()))
       .contains(uid)
 
+  /** The owner always has WRITE, whatever their own access row says. */
   def privilegeOf[R <: Record, A <: Record](
       ctx: DSLContext,
       resource: ResourceTables[R, A],
       id: Integer,
       uid: Integer
   ): PrivilegeEnum =
-    Option(
-      ctx
-        .select(resource.privilegeField)
-        .from(resource.accessTable)
-        .where(
-          resource.accessIdField
-            .eq(id)
-            .and(resource.accessUidField.eq(uid))
-        )
-        .fetchOneInto(classOf[PrivilegeEnum])
-    ).getOrElse(PrivilegeEnum.NONE)
+    if (userOwns(ctx, resource, id, uid)) PrivilegeEnum.WRITE
+    else

Review Comment:
   Added OwnerAccess.privilege(isOwner, granted), now used by ResourceAccess, unified search and ComputingUnitAccess.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4380432761


##########
common/auth/src/main/scala/org/apache/texera/auth/util/OwnerAccess.scala:
##########
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.texera.auth.util
+
+import jakarta.ws.rs.ForbiddenException
+import org.apache.texera.dao.jooq.generated.enums.PrivilegeEnum
+
+/** The rule every shared resource applies to its owner. */
+object OwnerAccess {
+
+  /** The owner always has WRITE; anyone else has what they were granted, or NONE. */
+  def privilege(isOwner: Boolean, granted: PrivilegeEnum): PrivilegeEnum =

Review Comment:
   fixed: granted is now by-name, so the lookup only runs for non-owners. A write check is back to one query, and a read check to two.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

Posted by "chenlica (via GitHub)" <gi...@apache.org>.
chenlica commented on PR #8890:
URL: https://github.com/apache/texera/pull/8890#issuecomment-6118675265

   @kunwp1 Please review this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #8890:
URL: https://github.com/apache/texera/pull/8890#issuecomment-6030691052

   <!-- texera-benchmarks-comment -->
   ## ⚠️ Benchmark changes need a look
   
   🟢 0 better · 🔴 9 worse · ⚪ 6 noise (<±5%) · 0 without baseline
   
   > Compared against main `b760489` benchmarked on **this same runner**, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.
   
   [Dashboard](https://apache.github.io/texera/dev/bench/) · [Run](https://github.com/apache/texera/actions/runs/37569315524)
   
   | | config | throughput | MB/s | latency | max Δ latest / 7d |
   |---|---|---:|---:|---:|---:|
   | 🔴 | bs=10 sw=10 sl=64 | 370 | 0.226 | 25,988/35,931/35,931 us | 🔴 +7.9% / 🔴 +165.9% |
   | 🔴 | bs=100 sw=10 sl=64 | 780 | 0.476 | 126,305/165,144/165,144 us | 🔴 +10.6% / 🔴 +76.1% |
   | 🔴 | bs=1000 sw=10 sl=64 | 912 | 0.556 | 1,089,525/1,201,842/1,201,842 us | 🔴 +6.0% / 🔴 +32.9% |
   
   <details><summary>Baseline details</summary>
   
   Latest main `b760489` from same runner
   
   | config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
   |---|---|---:|---:|---:|---:|---:|
   | bs=10 sw=10 sl=64 | throughput | 370 tuples/sec | 397 tuples/sec | 963.37 tuples/sec | -6.8% | -61.6% |
   | bs=10 sw=10 sl=64 | MB/s | 0.226 MB/s | 0.242 MB/s | 0.588 MB/s | -6.6% | -61.6% |
   | bs=10 sw=10 sl=64 | p50 | 25,988 us | 25,741 us | 10,998 us | +1.0% | +136.3% |
   | bs=10 sw=10 sl=64 | p95 | 35,931 us | 33,297 us | 13,515 us | +7.9% | +165.9% |
   | bs=10 sw=10 sl=64 | p99 | 35,931 us | 33,297 us | 16,850 us | +7.9% | +113.2% |
   | bs=100 sw=10 sl=64 | throughput | 780 tuples/sec | 817 tuples/sec | 1,235 tuples/sec | -4.5% | -36.9% |
   | bs=100 sw=10 sl=64 | MB/s | 0.476 MB/s | 0.499 MB/s | 0.754 MB/s | -4.6% | -36.9% |
   | bs=100 sw=10 sl=64 | p50 | 126,305 us | 120,202 us | 87,833 us | +5.1% | +43.8% |
   | bs=100 sw=10 sl=64 | p95 | 165,144 us | 149,338 us | 93,795 us | +10.6% | +76.1% |
   | bs=100 sw=10 sl=64 | p99 | 165,144 us | 149,338 us | 103,718 us | +10.6% | +59.2% |
   | bs=1000 sw=10 sl=64 | throughput | 912 tuples/sec | 923 tuples/sec | 1,273 tuples/sec | -1.2% | -28.4% |
   | bs=1000 sw=10 sl=64 | MB/s | 0.556 MB/s | 0.564 MB/s | 0.777 MB/s | -1.4% | -28.4% |
   | bs=1000 sw=10 sl=64 | p50 | 1,089,525 us | 1,086,939 us | 861,707 us | +0.2% | +26.4% |
   | bs=1000 sw=10 sl=64 | p95 | 1,201,842 us | 1,133,353 us | 904,523 us | +6.0% | +32.9% |
   | bs=1000 sw=10 sl=64 | p99 | 1,201,842 us | 1,133,353 us | 931,473 us | +6.0% | +29.0% |
   
   </details>
   
   <details><summary>Raw CSV</summary>
   
   ```csv
   config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
   0,10,10,64,20,541.06,200,128000,370,0.226,25987.80,35931.41,35931.41
   1,100,10,64,20,2565.61,2000,1280000,780,0.476,126305.43,165144.20,165144.20
   2,1000,10,64,20,21938.12,20000,12800000,912,0.556,1089525.49,1201841.53,1201841.53
   ```
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4343394165


##########
computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitAccessResource.scala:
##########
@@ -165,6 +166,9 @@ class ComputingUnitAccessResource {
     }
 
     val granteeId = resolveUidByEmail(email)
+    if (isOwner(cuid, granteeId)) {
+      throw new ForbiddenException("You cannot modify the owner's permissions!")
+    }

Review Comment:
   Added OwnerAccess.requireNotOwner in common/auth, used for datasets, models and computing units. WorkflowAccessResource uses the same message constant but keeps its own exception, since amber is still on javax JAX-RS.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4380683697


##########
amber/src/main/scala/org/apache/texera/web/resource/dashboard/hub/HubResource.scala:
##########
@@ -280,18 +280,22 @@ object HubResource {
     * Hydrates ids of one LakeFS-backed resource into hub entries. Unsizable resources are
     * dropped; ids are de-duplicated because the access join can match one twice.
     */
-  def fetchDashboardVersionedResourcesByIds(
+  /** The access join is narrowed to `uid`, so each row carries only the viewer's own grant. */

Review Comment:
   Two doc comments are now stacked here. The first describes `fetchDashboardVersionedResourcesByIds`, and its "the access join can match one twice" reason no longer holds now that the join is scoped to the viewer. Moving it onto the public method and dropping that clause would fix both. The `groupBy`/`distinctBy` that existed for that reason may be droppable too. Also, the viewer join condition here is a duplicate of the one in `VersionedResourceSearchQueryBuilder`. A small helper on `VersionedResourceTables` would keep the two in step.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 merged PR #8890:
URL: https://github.com/apache/texera/pull/8890


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4328882193


##########
computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitAccessResource.scala:
##########
@@ -139,6 +139,7 @@ class ComputingUnitAccessResource {
       computingUnitUserAccessDao
         .fetchByCuid(cuid)
         .asScala
+        .filterNot(access => isOwner(cuid, access.getUid))

Review Comment:
   This method never checks that the caller can see the unit. Any logged-in user can list the collaborators (emails, names, privileges) of any cuid, whereas the dataset and model access lists require read access first. Also, `isOwner` runs a separate query for every row here. Loading the unit once (for both the read check and the owner uid) would fix both.



##########
computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitManagingResource.scala:
##########
@@ -884,22 +884,15 @@ class ComputingUnitManagingResource {
       statusReason = if (isOwner) statusReason else None,
       metrics = ComputingUnitHelpers.getComputingUnitMetrics(unit),
       isOwner = isOwner,
-      accessPrivilege = {
-        val cuAccessDao = new ComputingUnitUserAccessDao(context.configuration())
-        val access = cuAccessDao
-          .fetchByUid(user.getUid)
-          .asScala
-          .find(access => access.getCuid.equals(cuid))
-
-        if (access.isDefined) {
-          access.get.getPrivilege
-        } else if (unit.getUid.equals(user.getUid)) {
-          PrivilegeEnum.WRITE
-        } else {
-          // Default privilege for non-owners without explicit access
-          PrivilegeEnum.NONE
-        }
-      },
+      accessPrivilege =
+        if (isOwner) PrivilegeEnum.WRITE
+        else
+          new ComputingUnitUserAccessDao(context.configuration())
+            .fetchByUid(user.getUid)
+            .asScala
+            .find(access => access.getCuid.equals(cuid))
+            .map(_.getPrivilege)
+            .getOrElse(PrivilegeEnum.NONE),

Review Comment:
   `ComputingUnitAccess.getComputingUnitAccess(cuid, uid)` in `common/auth` already applies exactly this rule (owner → WRITE, else the grant, else NONE) in a single query, and this service already depends on `Auth`. Reusing it would keep the owner rule in one place for computing units. 



##########
computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitAccessResource.scala:
##########
@@ -165,6 +166,9 @@ class ComputingUnitAccessResource {
     }
 
     val granteeId = resolveUidByEmail(email)
+    if (isOwner(cuid, granteeId)) {
+      throw new ForbiddenException("You cannot modify the owner's permissions!")
+    }

Review Comment:
   This guard is repeated in `revokeAccess`, and the message now appears in four places (here, revoke, `ResourceAccess.requireNotOwner`, and `WorkflowAccessResource`). Can you add a small helper?



##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -69,32 +69,34 @@ object ResourceAccess {
     ).flatMap(record => Option(record.value1()))
       .contains(uid)
 
+  /** The owner always has WRITE, whatever their own access row says. */
   def privilegeOf[R <: Record, A <: Record](
       ctx: DSLContext,
       resource: ResourceTables[R, A],
       id: Integer,
       uid: Integer
   ): PrivilegeEnum =
-    Option(
-      ctx
-        .select(resource.privilegeField)
-        .from(resource.accessTable)
-        .where(
-          resource.accessIdField
-            .eq(id)
-            .and(resource.accessUidField.eq(uid))
-        )
-        .fetchOneInto(classOf[PrivilegeEnum])
-    ).getOrElse(PrivilegeEnum.NONE)
+    if (userOwns(ctx, resource, id, uid)) PrivilegeEnum.WRITE
+    else
+      Option(
+        ctx
+          .select(resource.privilegeField)
+          .from(resource.accessTable)
+          .where(
+            resource.accessIdField
+              .eq(id)
+              .and(resource.accessUidField.eq(uid))
+          )
+          .fetchOneInto(classOf[PrivilegeEnum])
+      ).getOrElse(PrivilegeEnum.NONE)
 
   def userHasWriteAccess[R <: Record, A <: Record](
       ctx: DSLContext,
       resource: ResourceTables[R, A],
       id: Integer,
       uid: Integer
   ): Boolean =
-    userOwns(ctx, resource, id, uid) ||
-      privilegeOf(ctx, resource, id, uid) == PrivilegeEnum.WRITE
+    privilegeOf(ctx, resource, id, uid) == PrivilegeEnum.WRITE
 
   def userHasReadAccess[R <: Record, A <: Record](

Review Comment:
   This method runs it twice: once through `userHasWriteAccess` and once directly. Computing the privilege once (`isPublic || privilegeOf != NONE`) would be both simpler and cheaper.



##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -286,6 +292,7 @@ object ResourceAccess {
   ): Response = {
     requireWriteAccess(ctx, resource, id, requesterUid)
     val granteeUid = new UserDao(ctx.configuration()).fetchOneByEmail(email).getUid

Review Comment:
   An unknown email makes `fetchOneByEmail` return null here, so revoke fails with a 500 while `grant` returns a 400 for the same input. Reusing the same check as `grant` would make the two endpoints behave alike.



##########
amber/src/main/scala/org/apache/texera/web/resource/dashboard/VersionedResourceTables.scala:
##########
@@ -90,13 +90,16 @@ trait VersionedResourceTables[Rec <: Record, P] extends BaseEntityTable with Laz
       uid: Integer
   ): Option[(Integer, DashboardClickableFileEntry)] = {
     val resource = pojo(record)
+    val isOwner = ownerUidOf(resource) == uid
     repositorySize(resource).map { size =>
       idOf(resource) -> entry(
         resource,
         record.into(USER).into(classOf[User]).getEmail,
-        Option(record.get(access.privilegeColumn, classOf[PrivilegeEnum]))
-          .getOrElse(PrivilegeEnum.NONE),
-        ownerUidOf(resource) == uid,
+        if (isOwner) PrivilegeEnum.WRITE
+        else
+          Option(record.get(access.privilegeColumn, classOf[PrivilegeEnum]))
+            .getOrElse(PrivilegeEnum.NONE),

Review Comment:
   Codecov still reports 2 uncovered lines here. 



##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -69,32 +69,34 @@ object ResourceAccess {
     ).flatMap(record => Option(record.value1()))
       .contains(uid)
 
+  /** The owner always has WRITE, whatever their own access row says. */
   def privilegeOf[R <: Record, A <: Record](
       ctx: DSLContext,
       resource: ResourceTables[R, A],
       id: Integer,
       uid: Integer
   ): PrivilegeEnum =
-    Option(
-      ctx
-        .select(resource.privilegeField)
-        .from(resource.accessTable)
-        .where(
-          resource.accessIdField
-            .eq(id)
-            .and(resource.accessUidField.eq(uid))
-        )
-        .fetchOneInto(classOf[PrivilegeEnum])
-    ).getOrElse(PrivilegeEnum.NONE)
+    if (userOwns(ctx, resource, id, uid)) PrivilegeEnum.WRITE
+    else

Review Comment:
   A tiny shared helper would keep the "owner gets WRITE, otherwise use the grant" rule in one place if it ever changes (e.g. admins).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on PR #8890:
URL: https://github.com/apache/texera/pull/8890#issuecomment-6329851844

   > Thanks for the update. My earlier points are addressed. The comments below are mostly smaller follow-ups.
   
   Thanks, Have worked on the follow ups. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4277722387


##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -311,6 +314,16 @@ object ResourceAccess {
       )
     }
 
+  private def requireNotOwner[R <: Record, A <: Record](

Review Comment:
   Done, privilegeOf, the list endpoints, the owner filter and unified search all treat the owner as WRITE, whatever their access row says.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4343390510


##########
computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitManagingResource.scala:
##########
@@ -884,22 +884,15 @@ class ComputingUnitManagingResource {
       statusReason = if (isOwner) statusReason else None,
       metrics = ComputingUnitHelpers.getComputingUnitMetrics(unit),
       isOwner = isOwner,
-      accessPrivilege = {
-        val cuAccessDao = new ComputingUnitUserAccessDao(context.configuration())
-        val access = cuAccessDao
-          .fetchByUid(user.getUid)
-          .asScala
-          .find(access => access.getCuid.equals(cuid))
-
-        if (access.isDefined) {
-          access.get.getPrivilege
-        } else if (unit.getUid.equals(user.getUid)) {
-          PrivilegeEnum.WRITE
-        } else {
-          // Default privilege for non-owners without explicit access
-          PrivilegeEnum.NONE
-        }
-      },
+      accessPrivilege =
+        if (isOwner) PrivilegeEnum.WRITE
+        else
+          new ComputingUnitUserAccessDao(context.configuration())
+            .fetchByUid(user.getUid)
+            .asScala
+            .find(access => access.getCuid.equals(cuid))
+            .map(_.getPrivilege)
+            .getOrElse(PrivilegeEnum.NONE),

Review Comment:
   Done, it now uses ComputingUnitAccess.getComputingUnitAccess.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "chenlica (via GitHub)" <gi...@apache.org>.
chenlica commented on PR #8890:
URL: https://github.com/apache/texera/pull/8890#issuecomment-6409417373

   @kunwp1 Can you review it again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4380026098


##########
common/auth/src/main/scala/org/apache/texera/auth/util/OwnerAccess.scala:
##########
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.texera.auth.util
+
+import jakarta.ws.rs.ForbiddenException
+import org.apache.texera.dao.jooq.generated.enums.PrivilegeEnum
+
+/** The rule every shared resource applies to its owner. */
+object OwnerAccess {
+
+  /** The owner always has WRITE; anyone else has what they were granted, or NONE. */
+  def privilege(isOwner: Boolean, granted: PrivilegeEnum): PrivilegeEnum =

Review Comment:
   `granted` is taken by value, so in `ResourceAccess.privilegeOf` the query now runs even when the caller is the owner. Before, `if (userOwns) WRITE else <query>` skipped it. That's one extra query on every owner check: a write check goes from 1 to 2 queries, a read check from 2 to 3. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #8890:
URL: https://github.com/apache/texera/pull/8890#issuecomment-6030653345

   ## [Codecov](https://app.codecov.io/gh/apache/texera/pull/8890?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 92.59%. Comparing base ([`b760489`](https://app.codecov.io/gh/apache/texera/commit/b76048948b64e9aa87509c627700f5573c955508?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`caa90a2`](https://app.codecov.io/gh/apache/texera/commit/caa90a257841ed8857122ee8633c3cc8161053d2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff            @@
   ##               main    #8890   +/-   ##
   =========================================
     Coverage     92.59%   92.59%           
     Complexity     5043     5043           
   =========================================
     Files          1252     1252           
     Lines         53583    53583           
     Branches       6672     6672           
   =========================================
     Hits          49615    49615           
     Misses         2319     2319           
     Partials       1649     1649           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | *Carryforward flag |
   |---|---|---|---|
   | [access-control-service](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `77.38% <ø> (ø)` | | Carriedforward from [b760489](https://app.codecov.io/gh/apache/texera/commit/b76048948b64e9aa87509c627700f5573c955508?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [agent-service](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `99.16% <ø> (ø)` | | Carriedforward from [b760489](https://app.codecov.io/gh/apache/texera/commit/b76048948b64e9aa87509c627700f5573c955508?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [amber](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `88.07% <ø> (ø)` | | Carriedforward from [b760489](https://app.codecov.io/gh/apache/texera/commit/b76048948b64e9aa87509c627700f5573c955508?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [computing-unit-managing-service](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `60.41% <ø> (ø)` | | Carriedforward from [b760489](https://app.codecov.io/gh/apache/texera/commit/b76048948b64e9aa87509c627700f5573c955508?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [config-service](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `87.37% <ø> (ø)` | | |
   | [file-service](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `81.53% <ø> (ø)` | | Carriedforward from [b760489](https://app.codecov.io/gh/apache/texera/commit/b76048948b64e9aa87509c627700f5573c955508?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [frontend](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `96.58% <ø> (ø)` | | Carriedforward from [b760489](https://app.codecov.io/gh/apache/texera/commit/b76048948b64e9aa87509c627700f5573c955508?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.73% <ø> (ø)` | | Carriedforward from [b760489](https://app.codecov.io/gh/apache/texera/commit/b76048948b64e9aa87509c627700f5573c955508?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [pyamber](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `98.58% <ø> (ø)` | | Carriedforward from [b760489](https://app.codecov.io/gh/apache/texera/commit/b76048948b64e9aa87509c627700f5573c955508?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [workflow-compiling-service](https://app.codecov.io/gh/apache/texera/pull/8890/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `74.09% <ø> (ø)` | | Carriedforward from [b760489](https://app.codecov.io/gh/apache/texera/commit/b76048948b64e9aa87509c627700f5573c955508?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   *This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/texera/pull/8890?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource): refuse changing or revoking the owner's access to a dataset or model [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #8890:
URL: https://github.com/apache/texera/pull/8890#issuecomment-6030619836

   <!-- backport-auto-label-report -->
   ### Backport auto-label report
   
   This `fix:` PR was checked against each actively-supported release branch. A `release/*` label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required **Backport Approvals** check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.
   
   | Release branch | Analysis |
   | --- | --- |
   | ✅ `release/v1.3` | Change detected on this branch — label added; this fix is queued to backport here. @mengw15 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested. |
   | ✅ `release/v1.2` | Change detected on this branch — label added; this fix is queued to backport here. @xuang7 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested. |
   
   _[Auto-label run](https://github.com/apache/texera/actions/runs/37569297871)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4343396256


##########
common/resource/src/main/scala/org/apache/texera/service/resource/ResourceAccess.scala:
##########
@@ -69,32 +69,34 @@ object ResourceAccess {
     ).flatMap(record => Option(record.value1()))
       .contains(uid)
 
+  /** The owner always has WRITE, whatever their own access row says. */
   def privilegeOf[R <: Record, A <: Record](
       ctx: DSLContext,
       resource: ResourceTables[R, A],
       id: Integer,
       uid: Integer
   ): PrivilegeEnum =
-    Option(
-      ctx
-        .select(resource.privilegeField)
-        .from(resource.accessTable)
-        .where(
-          resource.accessIdField
-            .eq(id)
-            .and(resource.accessUidField.eq(uid))
-        )
-        .fetchOneInto(classOf[PrivilegeEnum])
-    ).getOrElse(PrivilegeEnum.NONE)
+    if (userOwns(ctx, resource, id, uid)) PrivilegeEnum.WRITE
+    else
+      Option(
+        ctx
+          .select(resource.privilegeField)
+          .from(resource.accessTable)
+          .where(
+            resource.accessIdField
+              .eq(id)
+              .and(resource.accessUidField.eq(uid))
+          )
+          .fetchOneInto(classOf[PrivilegeEnum])
+      ).getOrElse(PrivilegeEnum.NONE)
 
   def userHasWriteAccess[R <: Record, A <: Record](
       ctx: DSLContext,
       resource: ResourceTables[R, A],
       id: Integer,
       uid: Integer
   ): Boolean =
-    userOwns(ctx, resource, id, uid) ||
-      privilegeOf(ctx, resource, id, uid) == PrivilegeEnum.WRITE
+    privilegeOf(ctx, resource, id, uid) == PrivilegeEnum.WRITE
 
   def userHasReadAccess[R <: Record, A <: Record](

Review Comment:
   Done: isPublic || privilegeOf != NONE.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4380909030


##########
amber/src/main/scala/org/apache/texera/web/resource/dashboard/hub/HubResource.scala:
##########
@@ -280,18 +280,22 @@ object HubResource {
     * Hydrates ids of one LakeFS-backed resource into hub entries. Unsizable resources are
     * dropped; ids are de-duplicated because the access join can match one twice.
     */
-  def fetchDashboardVersionedResourcesByIds(
+  /** The access join is narrowed to `uid`, so each row carries only the viewer's own grant. */

Review Comment:
   Thanks! Done: moved the doc onto fetchDashboardVersionedResourcesByIds without the outdated clause, dropped the groupBy/distinctBy (one row per id now), and added VersionedResourceTables.joinWithViewerAccessAndOwner, which both the Hub and search now use.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(resource, computing-unit): keep owners' full access to their datasets, models and computing units [texera]

Posted by "tanishqgandhi1908 (via GitHub)" <gi...@apache.org>.
tanishqgandhi1908 commented on code in PR #8890:
URL: https://github.com/apache/texera/pull/8890#discussion_r4343388935


##########
computing-unit-managing-service/src/main/scala/org/apache/texera/service/resource/ComputingUnitAccessResource.scala:
##########
@@ -139,6 +139,7 @@ class ComputingUnitAccessResource {
       computingUnitUserAccessDao
         .fetchByCuid(cuid)
         .asScala
+        .filterNot(access => isOwner(cuid, access.getUid))

Review Comment:
   Fixed: it now loads the unit and its grants once, returns 403 unless the caller owns the unit or holds a grant on it, and filters the owner by uid without extra queries.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org