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

[PR] fix: complete @RolesAllowed enforcement across microservices [texera]

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

   ### What changes were proposed in this PR?
   
     Finishes wiring JAX-RS role enforcement across every Texera microservice. Each service's Jersey environment now registers the standard three-feature stack:
   
     1. `AuthDynamicFeature(JwtAuthFilter)` - authentication (reads the JWT, attaches a `SessionUser`).
     2. `AuthValueFactoryProvider.Binder(SessionUser)` - injects `@Auth user` into resource methods.
     3. `RolesAllowedDynamicFeature` - authorization (enforces `@RolesAllowed` / `@PermitAll` / `@DenyAll`).
   
     #5049 added this trio to three services; this PR extends it to `file-service` and `access-control-service`, fixes the filter priority on the shared `JwtAuthFilter` so authentication runs before authorization, and tags every endpoint with the right policy.
   
     ### What this PR adds, and where
   
     - **`common/auth/JwtAuthFilter`** - `@Priority(Priorities.AUTHENTICATION)` so it runs before `RolesAllowedRequestFilter`. Added `jakarta.annotation-api` dependency.
     - **`FileService.run` and `AccessControlService.run`** - register `RolesAllowedDynamicFeature`; the existing `@RolesAllowed` annotations in those services become live.
     - **`@PermitAll`** on endpoints that must serve unauthenticated traffic: `ConfigResource` bootstrap endpoints, the six public-dataset endpoints on `DatasetResource`, and `AccessControlResource` (the Envoy ExtAuth callback).
     - **`@RolesAllowed("REGULAR","ADMIN")`** on the LiteLLM copilot proxies.
     - **`AuthResource.register`** - new local signups now default to `REGULAR` instead of `RESTRICTED`, so registered users can immediately use role-gated endpoints.
     - **`FileService.run` reorder** - Jersey registration moved before infra init, mirroring `ConfigService.run` and making the registrations unit-testable.
   
     ### Implementation details
   
     - Method-level annotations beat class-level; unannotated methods default to open (so unannotated `HealthCheckResource`s stay public for k8s probes).
     - `getDatasetCover` is `@PermitAll` because it accepts optional auth; the method body re-checks access.
     - WebSocket endpoints are not affected — they use a separate query-param token path.
   
     ### Tests added
     
     `JwtAuthFilterSpec`, `ConfigResourceSpec`, `AccessControlResourcePermissionsSpec`, `DatasetResourcePermissionsSpec`, `FileServiceRunSpec`, plus an added assertion in `AccessControlServiceRunSpec`. Together, they pin the priority annotation, the public/private policy to every changed endpoint, and the registration of `RolesAllowedDynamicFeature` in the two newly enforced services.
   
     ### Any related issues, documentation, or discussions?
   
     Closes: #4904
     Fixes issue found and addressed in: #5173 and #5049
     
     ### How was this PR tested?
   
     Added six specs covering the filter priority, the `@PermitAll`/`@RolesAllowed` tags on each affected resource, and `RolesAllowedDynamicFeature` registration in both newly-enforced services.
   
     Manually verified end-to-end
   
     ### Was this PR authored or co-authored using generative AI tooling?
   
     Co-authored with Claude Opus 4.7 in compliance with ASF Generative Tooling Guidance.


-- 
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: complete @RolesAllowed enforcement across microservices [texera]

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

   /request-review @carloea2 @aglinxinyuan @Yicong-Huang 


-- 
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: complete @RolesAllowed enforcement across microservices [texera]

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


##########
amber/src/main/scala/org/apache/texera/web/resource/auth/AuthResource.scala:
##########
@@ -110,7 +110,7 @@ class AuthResource {
         val user = new User
         user.setName(username)
         user.setEmail(username)
-        user.setRole(UserRoleEnum.RESTRICTED)

Review Comment:
   fixed



-- 
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: complete @RolesAllowed enforcement across microservices [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #5198:
URL: https://github.com/apache/texera/pull/5198#discussion_r3331814533


##########
amber/src/main/scala/org/apache/texera/web/resource/auth/AuthResource.scala:
##########
@@ -110,7 +110,7 @@ class AuthResource {
         val user = new User
         user.setName(username)
         user.setEmail(username)
-        user.setRole(UserRoleEnum.RESTRICTED)

Review Comment:
   this should not be changed



-- 
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(auth): enforce @RolesAllowed in file-service by registering RolesAllowedDynamicFeature [texera]

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


-- 
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(auth): enforce @RolesAllowed in file-service by registering RolesAllowedDynamicFeature [texera]

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


##########
file-service/src/test/scala/org/apache/texera/service/resource/DatasetResourcePermissionsSpec.scala:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.service.resource
+
+import jakarta.annotation.security.PermitAll
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class DatasetResourcePermissionsSpec extends AnyFlatSpec with Matchers {
+
+  // Once RolesAllowedDynamicFeature is registered in FileService, every method
+  // on DatasetResource is enforced. These endpoints serve unauthenticated hub
+  // visitors browsing public datasets — they must remain reachable without a JWT.
+  private val publicEndpointMethods = Seq(
+    "getPublicPresignedUrl",
+    "getPublicPresignedUrlWithS3",
+    "getPublicDatasetVersionList",
+    "retrievePublicDatasetVersionRootFileNodes",
+    "getPublicDataset",
+    "getDatasetCover"
+  )
+
+  publicEndpointMethods.foreach { methodName =>
+    s"DatasetResource.$methodName" should "be @PermitAll so unauthenticated visitors can hit it" in {
+      val methods = classOf[DatasetResource].getMethods.filter(_.getName == methodName)
+      methods should not be empty
+      methods.foreach { m =>
+        withClue(s"method $methodName missing @PermitAll: ") {
+          m.getAnnotation(classOf[PermitAll]) should not be null
+        }
+      }
+    }
+  }

Review Comment:
   Updated the spec to check all endpoints, not just the public ones. It now verifies three things: every endpoint has either `@PermitAll` or `@RolesAllowed` (so none is accidentally left open), every non-public endpoint requires `@RolesAllowed(REGULAR, ADMIN)`, and the public ones stay `@PermitAll`. This also caught `getDatasetCoverUrl`, a public endpoint the old list had missed.



-- 
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(auth): enforce @RolesAllowed in file-service by registering RolesAllowedDynamicFeature [texera]

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

   @Yicong-Huang / @xuang7 I fixed the CI issue. Please add to the merge queue when available. 


-- 
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: complete @RolesAllowed enforcement across microservices [texera]

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

   /request-review @aglinxinyuan @Yicong-Huang


-- 
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(auth): enforce @RolesAllowed in file-service by registering RolesAllowedDynamicFeature [texera]

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

   @Yicong-Huang / @xuang7 I fixed the CI issue. Please add to the merge queue when available. 


-- 
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: complete @RolesAllowed enforcement across microservices [texera]

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

   @carloea2 please also review and test if available


-- 
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(auth): enforce @RolesAllowed in file-service by registering RolesAllowedDynamicFeature [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #5198:
URL: https://github.com/apache/texera/pull/5198#discussion_r3368562257


##########
file-service/src/test/scala/org/apache/texera/service/resource/DatasetResourcePermissionsSpec.scala:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.service.resource
+
+import jakarta.annotation.security.PermitAll
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class DatasetResourcePermissionsSpec extends AnyFlatSpec with Matchers {
+
+  // Once RolesAllowedDynamicFeature is registered in FileService, every method
+  // on DatasetResource is enforced. These endpoints serve unauthenticated hub
+  // visitors browsing public datasets — they must remain reachable without a JWT.
+  private val publicEndpointMethods = Seq(
+    "getPublicPresignedUrl",
+    "getPublicPresignedUrlWithS3",
+    "getPublicDatasetVersionList",
+    "retrievePublicDatasetVersionRootFileNodes",
+    "getPublicDataset",
+    "getDatasetCover"
+  )
+
+  publicEndpointMethods.foreach { methodName =>
+    s"DatasetResource.$methodName" should "be @PermitAll so unauthenticated visitors can hit it" in {
+      val methods = classOf[DatasetResource].getMethods.filter(_.getName == methodName)
+      methods should not be empty
+      methods.foreach { m =>
+        withClue(s"method $methodName missing @PermitAll: ") {
+          m.getAnnotation(classOf[PermitAll]) should not be null
+        }
+      }
+    }
+  }

Review Comment:
   can we also validate non-public endpoints?



-- 
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: complete @RolesAllowed enforcement across microservices [texera]

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

   ## [Codecov](https://app.codecov.io/gh/apache/texera/pull/5198?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 45.42%. Comparing base ([`8633188`](https://app.codecov.io/gh/apache/texera/commit/8633188757e255f29cf43a9122aaef4dc7b8085a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ca257df`](https://app.codecov.io/gh/apache/texera/commit/ca257df09de9885744b201cf3f525cb165162376?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    #5198      +/-   ##
   ============================================
   + Coverage     45.41%   45.42%   +0.01%     
     Complexity     2222     2222              
   ============================================
     Files          1042     1042              
     Lines         39989    39982       -7     
     Branches       4260     4260              
   ============================================
   + Hits          18160    18161       +1     
   + Misses        20716    20708       -8     
     Partials       1113     1113              
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/texera/pull/5198/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/5198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.88% <100.00%> (+0.34%)` | :arrow_up: | |
   | [agent-service](https://app.codecov.io/gh/apache/texera/pull/5198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `33.76% <ø> (ø)` | | Carriedforward from [8633188](https://app.codecov.io/gh/apache/texera/commit/8633188757e255f29cf43a9122aaef4dc7b8085a?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/5198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `45.78% <ø> (+<0.01%)` | :arrow_up: | Carriedforward from [8633188](https://app.codecov.io/gh/apache/texera/commit/8633188757e255f29cf43a9122aaef4dc7b8085a?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/5198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (ø)` | | |
   | [config-service](https://app.codecov.io/gh/apache/texera/pull/5198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (ø)` | | |
   | [file-service](https://app.codecov.io/gh/apache/texera/pull/5198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `32.79% <ø> (+0.60%)` | :arrow_up: | Carriedforward from [8633188](https://app.codecov.io/gh/apache/texera/commit/8633188757e255f29cf43a9122aaef4dc7b8085a?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/5198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.81% <ø> (ø)` | | Carriedforward from [8633188](https://app.codecov.io/gh/apache/texera/commit/8633188757e255f29cf43a9122aaef4dc7b8085a?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [python](https://app.codecov.io/gh/apache/texera/pull/5198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `90.50% <ø> (ø)` | | Carriedforward from [8633188](https://app.codecov.io/gh/apache/texera/commit/8633188757e255f29cf43a9122aaef4dc7b8085a?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/5198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.81% <ø> (ø)` | | Carriedforward from [8633188](https://app.codecov.io/gh/apache/texera/commit/8633188757e255f29cf43a9122aaef4dc7b8085a?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 Sentry](https://app.codecov.io/gh/apache/texera/pull/5198?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>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :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(auth): enforce @RolesAllowed in file-service by registering RolesAllowedDynamicFeature [texera]

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

   I suggest we backport this as well 
   
   cc @xuang7 


-- 
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(auth): enforce @RolesAllowed in file-service by registering RolesAllowedDynamicFeature [texera]

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

   Backport to [`release/v1.2`](https://github.com/apache/texera/tree/release/v1.2) succeeded as [`7dc17c0`](https://github.com/apache/texera/commit/7dc17c03ef425969948ea5412f85e99d52dfe1b2). [Run](https://github.com/apache/texera/actions/runs/27236787012)


-- 
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