Repository navigation
fix: enforce @RolesAllowed on microservice resources - #5199
Conversation
Re-applies apache#5049 (revert in apache#5173) and additionally marks the two pre-login ConfigResource endpoints (/config/gui, /config/user-system) as @permitAll so the frontend's APP_INITIALIZER can still bootstrap once role enforcement is on. Adds an HTTP-pipeline regression test that fires unauthenticated requests through JwtAuthFilter + RolesAllowedDynamicFeature and asserts the two pre-login endpoints return 200 while a sibling @RolesAllowed probe returns 403. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5199 +/- ##
============================================
- Coverage 49.78% 49.63% -0.15%
+ Complexity 2415 2413 -2
============================================
Files 1052 1052
Lines 40755 40750 -5
Branches 4355 4355
============================================
- Hits 20289 20228 -61
- Misses 19256 19315 +59
+ Partials 1210 1207 -3
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@Yicong-Huang I raised a similar pr to fix this. #5198 |
I hope to minimize the change, this PR is reapplying #5049 with only two more line diff about permit all usage on configservice. could you please help test this one? |
That makes sense. I can help test and review later today when I get back home. |
|
Shouldn’t Matthew’s PR have priority? Also this PR is bigger |
|
I believe that this PR focuses on reimplementing the previous PR without its problems, while my PR aims to extend the coverage of @RolesAllowed (to address the issue). I think @Yicong-Huang can merge this one, and I'll rebase mine on top as a complementary PR for now. |
|
@Ma77Ball can we prioritize this PR? could you help verify if the changes are enough? |
Ma77Ball
left a comment
There was a problem hiding this comment.
Overall LGTM. I confirmed that all the services look and work well. I did leave a couple of minor comments/suggestions.
…ce/ConfigResource.scala Co-authored-by: Matthew B. <[email protected]> Signed-off-by: Yicong Huang <[email protected]>
…ce/ConfigResourceAuthSpec.scala Co-authored-by: Matthew B. <[email protected]> Signed-off-by: Yicong Huang <[email protected]>
…ServiceRunSpec.scala Co-authored-by: Matthew B. <[email protected]> Signed-off-by: Yicong Huang <[email protected]>
…ce/ConfigResourceAuthSpec.scala Co-authored-by: Matthew B. <[email protected]> Signed-off-by: Yicong Huang <[email protected]>
Thanks for helping on testing it. I will find time to test it tomorrow myself. I will also address the remaining comments. |
…ity with the other two services ComputingUnitManagingService and WorkflowCompilingService already factor the JWT + @Auth + RolesAllowedDynamicFeature trio into a registerAuthFeatures helper on the companion object; ConfigService inlined the same three lines. Pull it out so all three services share the same shape and an addition or reorder in one stays mirrored in the others. As a knock-on, ConfigServiceRunSpec can target the helper directly the same way the peer specs do, dropping the intercept[Exception] / SqlServer-throws trick it previously needed to short-circuit run().
|
@aglinxinyuan @bobbai00 can you also help review this one? |
|
The change looks good to me. Please test it locally and make sure all micro services are accessible. |
…before RolesAllowed enforcement Without an explicit @priority, JwtAuthFilter defaulted to Priorities.USER (5000) while Jersey's RolesAllowedRequestFilter sits at AUTHORIZATION (2000), so the role check ran *before* the JWT was parsed. Result: every @RolesAllowed endpoint on config-service, computing-unit-managing-service, and workflow-compiling-service rejected even valid admin JWTs with 403 ("User not authorized.") instead of letting the request through. Tagging the filter with @priority(Priorities.AUTHENTICATION) restores the standard auth → authz ordering that amber's toastshaman-based path gets implicitly via AuthFilter. ConfigResourceAuthSpec gains a positive-direction test that mints a valid admin token via JwtAuth.jwtToken and asserts 200 from an @RolesAllowed probe — without it, the no-auth-403 case still passes regardless of the priority bug, which is how the regression slipped through the original spec. Adds jakarta.annotation-api to common/auth deps for the @priority symbol.
|
@Yicong-Huang This PR introduces and updates some direct dependencies. Therefore CI fails: https://github.com/apache/texera/actions/runs/26726942147/job/78763745189?pr=5199. Can you follow the instructions in the error message to fix it ? Meanwhile, I will test your PR locally |
…d NOTICE-binary The previous commit added jakarta.annotation-api to common/auth so the @priority annotation on JwtAuthFilter resolves. amber pulls common/auth transitively, so the new jar lands in amber's universal dist and trips bin/licensing/check_binary_deps.py with 'NEW JVM jars not claimed by LICENSE-binary'. Add the bullet under the EPL-2.0-with-Classpath-Exception section and bubble the upstream Eclipse Foundation NOTICE through to amber/NOTICE-binary, mirroring how workflow-compiling-service already records the same dependency.
…oints (apache#5305) ### What changes were proposed in this PR? `config-service` no longer broadcasts the full GUI configuration to anonymous callers. The four fields the frontend actually needs before login (`localLogin`, `googleLogin`, `defaultLocalUser`, `attributionEnabled`) move to a new `GET /api/config/pre-login` (`@PermitAll`). `GET /api/config/gui` and `GET /api/config/user-system` are now `@RolesAllowed("REGULAR", "ADMIN")` and only answer authenticated traffic. On the frontend, `GuiConfigService.load()` always fetches `/config/pre-login` at `APP_INITIALIZER`. When a JWT is already in `localStorage` (browser reload while logged in), it chains `/config/gui` + `/config/user-system` in the same await so the full config is in memory before any post-login component mounts. `UserService.handleAccessToken` does the same chaining on a fresh login so `loginWithExistingToken` (which reads `config.env.inviteOnly`) runs only after the authenticated config has resolved. Expired-token 403s on the post-login fetch are caught so a stale `localStorage` token cannot block bootstrap — that was the exact failure mode that caused apache#5025 to revert the earlier eager-401 lockdown. ### Any related issues, documentation, discussions? Closes apache#5304. Related: apache#4901 (eager-401 from `JwtAuthFilter`), apache#5025 (revert that broke `ConfigService` bootstrap last time we attempted a similar lockdown), apache#5199 (re-applied `@RolesAllowed` enforcement on the microservices, with `@PermitAll` opt-out for the two pre-login endpoints). ### How was this PR tested? Added unit tests covering pre-login / gui / user-system access with and without a valid Bearer token, the orchestrator's branching on a stored token, the 403 fallback, and the `UserService.handleAccessToken` ordering guarantee. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.7 --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
### What changes were proposed in this PR? `LiteLLMProxyResource` (`/chat/*`) and `LiteLLMModelsResource` (`/models`) in `access-control-service` were `@PermitAll` — they contain no auth check beyond a `guiWorkflowWorkspaceCopilotEnabled` feature flag, so any anonymous caller could spend the deployment's LiteLLM credits whenever Copilot was on. PR #5404 left the annotations in place to preserve pre-eager-filter behavior and deferred the hardening decision; this picks it back up. Both classes now use `@RolesAllowed(Array("REGULAR", "ADMIN"))`. The JwtAuthFilter from #5404 runs at `Priorities.AUTHENTICATION`, so missing tokens fall to a 401 from the filter and bad-role tokens fall through to a 403 from Jersey's role check. `access-control-service` was the one microservice that hadn't picked up `RolesAllowedDynamicFeature` when #5199 added it elsewhere, so this PR also registers the feature in `AccessControlService.scala` — otherwise the annotations would have been decorative. `AccessControlServiceRunSpec` is updated to pin the registration so a future refactor can't quietly drop it and send us back to anonymous-LLM-access. ### Any related issues, documentation, discussions? Closes #5420. Follow-up hardening for #5404. ### How was this PR tested? `sbt AccessControlService/test` (22 cases) and `sbt scalafmtCheckAll` clean. Manual verification against a running access-control-service: anonymous `curl http://localhost:8081/api/models` returns 401 with `WWW-Authenticate: Bearer realm="texera"` instead of the pre-PR 200; a REGULAR-role bearer token gets through to LiteLLM as expected. ### Was this PR authored or co-authored using generative AI tooling? (backported from commit afc5f98) Generated-by: Claude Code (Opus 4.7)
…che#5421) ### What changes were proposed in this PR? `LiteLLMProxyResource` (`/chat/*`) and `LiteLLMModelsResource` (`/models`) in `access-control-service` were `@PermitAll` — they contain no auth check beyond a `guiWorkflowWorkspaceCopilotEnabled` feature flag, so any anonymous caller could spend the deployment's LiteLLM credits whenever Copilot was on. PR apache#5404 left the annotations in place to preserve pre-eager-filter behavior and deferred the hardening decision; this picks it back up. Both classes now use `@RolesAllowed(Array("REGULAR", "ADMIN"))`. The JwtAuthFilter from apache#5404 runs at `Priorities.AUTHENTICATION`, so missing tokens fall to a 401 from the filter and bad-role tokens fall through to a 403 from Jersey's role check. `access-control-service` was the one microservice that hadn't picked up `RolesAllowedDynamicFeature` when apache#5199 added it elsewhere, so this PR also registers the feature in `AccessControlService.scala` — otherwise the annotations would have been decorative. `AccessControlServiceRunSpec` is updated to pin the registration so a future refactor can't quietly drop it and send us back to anonymous-LLM-access. ### Any related issues, documentation, discussions? Closes apache#5420. Follow-up hardening for apache#5404. ### How was this PR tested? `sbt AccessControlService/test` (22 cases) and `sbt scalafmtCheckAll` clean. Manual verification against a running access-control-service: anonymous `curl http://localhost:8081/api/models` returns 401 with `WWW-Authenticate: Bearer realm="texera"` instead of the pre-PR 200; a REGULAR-role bearer token gets through to LiteLLM as expected. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 4.7)
…AllowedDynamicFeature (#5198) ### What changes were proposed in this PR? Registers Jersey's `RolesAllowedDynamicFeature` in `file-service`'s Jersey environment so the `@RolesAllowed` / `@PermitAll` annotations already present on `DatasetResource` are actually enforced. `file-service` registered `JwtAuthFilter` (authentication) and the `AuthValueFactoryProvider.Binder` (so `@Auth user` injects), but never `RolesAllowedDynamicFeature` (authorization). The ~20 `@RolesAllowed(Array("REGULAR", "ADMIN"))` annotations on `DatasetResource` were therefore decorative: any valid JWT reached the resource method regardless of role. This adds the one missing registration. ```scala // Enforce @RolesAllowed annotations on resource methods environment.jersey.register(classOf[RolesAllowedDynamicFeature]) ``` Once enforcement is live, the six public-dataset endpoints (`getPublicPresignedUrl`, `getPublicPresignedUrlWithS3`, `getPublicDatasetVersionList`, `retrievePublicDatasetVersionRootFileNodes`, `getPublicDataset`, `getDatasetCover`) must stay reachable without a JWT for anonymous hub visitors. They are already `@PermitAll` on `main`; the new spec pins that so a future refactor cannot silently lock them out. ### Scope note This PR was originally "complete @RolesAllowed enforcement across microservices." Since then the rest of that work has landed or is in flight on `main`, so this PR has been narrowed to the one remaining gap: - `config-service`, `computing-unit-managing-service`, `workflow-compiling-service`: done in #5049 / #5199. - `JwtAuthFilter` priority + eager-401 + `@PermitAll` opt-out: done in #5404. - `access-control-service` (LiteLLM proxy hardening + feature registration): handled by #5421 (@Yicong-Huang). - **`file-service`: this PR.** With this and #5421, every microservice that uses `@RolesAllowed` enforces it, closing out #4904. ### Any related issues, documentation, or discussions? Closes #5433. Follow-up to #4904; companion to #5421. ### How was this PR tested? Added `DatasetResourcePermissionsSpec`, which verifies the six public-dataset endpoints carry `@PermitAll` so they remain anonymous-accessible after enforcement is enabled. `file-service` and the auth modules compile clean. Existing `DatasetResource` `@RolesAllowed` annotations are unchanged. ### Was this PR authored or co-authored using generative AI tooling? Co-authored with Claude Opus 4.8 in compliance with ASF Generative Tooling Guidance. --------- (backported from commit 7b7a5c6) Co-authored-by: Yicong Huang <[email protected]>
…AllowedDynamicFeature (apache#5198) ### What changes were proposed in this PR? Registers Jersey's `RolesAllowedDynamicFeature` in `file-service`'s Jersey environment so the `@RolesAllowed` / `@PermitAll` annotations already present on `DatasetResource` are actually enforced. `file-service` registered `JwtAuthFilter` (authentication) and the `AuthValueFactoryProvider.Binder` (so `@Auth user` injects), but never `RolesAllowedDynamicFeature` (authorization). The ~20 `@RolesAllowed(Array("REGULAR", "ADMIN"))` annotations on `DatasetResource` were therefore decorative: any valid JWT reached the resource method regardless of role. This adds the one missing registration. ```scala // Enforce @RolesAllowed annotations on resource methods environment.jersey.register(classOf[RolesAllowedDynamicFeature]) ``` Once enforcement is live, the six public-dataset endpoints (`getPublicPresignedUrl`, `getPublicPresignedUrlWithS3`, `getPublicDatasetVersionList`, `retrievePublicDatasetVersionRootFileNodes`, `getPublicDataset`, `getDatasetCover`) must stay reachable without a JWT for anonymous hub visitors. They are already `@PermitAll` on `main`; the new spec pins that so a future refactor cannot silently lock them out. ### Scope note This PR was originally "complete @RolesAllowed enforcement across microservices." Since then the rest of that work has landed or is in flight on `main`, so this PR has been narrowed to the one remaining gap: - `config-service`, `computing-unit-managing-service`, `workflow-compiling-service`: done in apache#5049 / apache#5199. - `JwtAuthFilter` priority + eager-401 + `@PermitAll` opt-out: done in apache#5404. - `access-control-service` (LiteLLM proxy hardening + feature registration): handled by apache#5421 (@Yicong-Huang). - **`file-service`: this PR.** With this and apache#5421, every microservice that uses `@RolesAllowed` enforces it, closing out apache#4904. ### Any related issues, documentation, or discussions? Closes apache#5433. Follow-up to apache#4904; companion to apache#5421. ### How was this PR tested? Added `DatasetResourcePermissionsSpec`, which verifies the six public-dataset endpoints carry `@PermitAll` so they remain anonymous-accessible after enforcement is enabled. `file-service` and the auth modules compile clean. Existing `DatasetResource` `@RolesAllowed` annotations are unchanged. ### Was this PR authored or co-authored using generative AI tooling? Co-authored with Claude Opus 4.8 in compliance with ASF Generative Tooling Guidance. --------- Co-authored-by: Yicong Huang <[email protected]>
…che#5421) ### What changes were proposed in this PR? `LiteLLMProxyResource` (`/chat/*`) and `LiteLLMModelsResource` (`/models`) in `access-control-service` were `@PermitAll` — they contain no auth check beyond a `guiWorkflowWorkspaceCopilotEnabled` feature flag, so any anonymous caller could spend the deployment's LiteLLM credits whenever Copilot was on. PR apache#5404 left the annotations in place to preserve pre-eager-filter behavior and deferred the hardening decision; this picks it back up. Both classes now use `@RolesAllowed(Array("REGULAR", "ADMIN"))`. The JwtAuthFilter from apache#5404 runs at `Priorities.AUTHENTICATION`, so missing tokens fall to a 401 from the filter and bad-role tokens fall through to a 403 from Jersey's role check. `access-control-service` was the one microservice that hadn't picked up `RolesAllowedDynamicFeature` when apache#5199 added it elsewhere, so this PR also registers the feature in `AccessControlService.scala` — otherwise the annotations would have been decorative. `AccessControlServiceRunSpec` is updated to pin the registration so a future refactor can't quietly drop it and send us back to anonymous-LLM-access. ### Any related issues, documentation, discussions? Closes apache#5420. Follow-up hardening for apache#5404. ### How was this PR tested? `sbt AccessControlService/test` (22 cases) and `sbt scalafmtCheckAll` clean. Manual verification against a running access-control-service: anonymous `curl http://localhost:8081/api/models` returns 401 with `WWW-Authenticate: Bearer realm="texera"` instead of the pre-PR 200; a REGULAR-role bearer token gets through to LiteLLM as expected. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 4.7)
…AllowedDynamicFeature (apache#5198) ### What changes were proposed in this PR? Registers Jersey's `RolesAllowedDynamicFeature` in `file-service`'s Jersey environment so the `@RolesAllowed` / `@PermitAll` annotations already present on `DatasetResource` are actually enforced. `file-service` registered `JwtAuthFilter` (authentication) and the `AuthValueFactoryProvider.Binder` (so `@Auth user` injects), but never `RolesAllowedDynamicFeature` (authorization). The ~20 `@RolesAllowed(Array("REGULAR", "ADMIN"))` annotations on `DatasetResource` were therefore decorative: any valid JWT reached the resource method regardless of role. This adds the one missing registration. ```scala // Enforce @RolesAllowed annotations on resource methods environment.jersey.register(classOf[RolesAllowedDynamicFeature]) ``` Once enforcement is live, the six public-dataset endpoints (`getPublicPresignedUrl`, `getPublicPresignedUrlWithS3`, `getPublicDatasetVersionList`, `retrievePublicDatasetVersionRootFileNodes`, `getPublicDataset`, `getDatasetCover`) must stay reachable without a JWT for anonymous hub visitors. They are already `@PermitAll` on `main`; the new spec pins that so a future refactor cannot silently lock them out. ### Scope note This PR was originally "complete @RolesAllowed enforcement across microservices." Since then the rest of that work has landed or is in flight on `main`, so this PR has been narrowed to the one remaining gap: - `config-service`, `computing-unit-managing-service`, `workflow-compiling-service`: done in apache#5049 / apache#5199. - `JwtAuthFilter` priority + eager-401 + `@PermitAll` opt-out: done in apache#5404. - `access-control-service` (LiteLLM proxy hardening + feature registration): handled by apache#5421 (@Yicong-Huang). - **`file-service`: this PR.** With this and apache#5421, every microservice that uses `@RolesAllowed` enforces it, closing out apache#4904. ### Any related issues, documentation, or discussions? Closes apache#5433. Follow-up to apache#4904; companion to apache#5421. ### How was this PR tested? Added `DatasetResourcePermissionsSpec`, which verifies the six public-dataset endpoints carry `@PermitAll` so they remain anonymous-accessible after enforcement is enabled. `file-service` and the auth modules compile clean. Existing `DatasetResource` `@RolesAllowed` annotations are unchanged. ### Was this PR authored or co-authored using generative AI tooling? Co-authored with Claude Opus 4.8 in compliance with ASF Generative Tooling Guidance. --------- Co-authored-by: Yicong Huang <[email protected]>
### What changes were proposed in this PR? Re-applies apache#5049 (Jersey `@RolesAllowed` enforcement on `config-service`, `computing-unit-managing-service`, and `workflow-compiling-service`) and additionally marks the two pre-login `ConfigResource` endpoints — `/api/config/gui` and `/api/config/user-system` — as `@PermitAll`. Those endpoints are loaded by `GuiConfigService.load()` in the Angular `APP_INITIALIZER` before any login, so once role enforcement is on they must keep returning `200` to unauthenticated callers; missing this was what broke bootstrap and got apache#5049 reverted in apache#5173. Everything outside `config-service` matches apache#5049 byte-for-byte. ### Any related issues, documentation, or discussions? Closes: apache#4904 Prior attempt: apache#5049, reverted by apache#5173. The bootstrap root cause was diagnosed inline at apache#5049 (comment). ### How was this PR tested? Added `ConfigResourceAuthSpec`: wires `ConfigResource` through the same `JwtAuthFilter` + `RolesAllowedDynamicFeature` pipeline production uses (via Dropwizard's `ResourceExtension`) and fires HTTP requests with no `Authorization` header. - `GET /config/gui` → expects `200` - `GET /config/user-system` → expects `200` - `GET /auth-probe` (an in-test `@RolesAllowed` resource) → expects `403` Manually tested. The `403` sanity guard ensures the feature is actually enforcing, so a future "200 everywhere" regression cannot silently slip through. Kept the three `*ServiceRunSpec` structural tests from apache#5049 verifying that `RolesAllowedDynamicFeature` is registered. Manual reproduction with `curl` against a local dev server confirmed the unauthenticated bootstrap path returns `200` while a low-role JWT against an annotated endpoint returns `403`. ### Was this PR authored or co-authored using generative AI tooling? Co-authored with Claude Opus 4.7 in compliance with ASF. --------- Signed-off-by: Yicong Huang <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> Co-authored-by: Matthew B. <[email protected]>
…oints (apache#5305) ### What changes were proposed in this PR? `config-service` no longer broadcasts the full GUI configuration to anonymous callers. The four fields the frontend actually needs before login (`localLogin`, `googleLogin`, `defaultLocalUser`, `attributionEnabled`) move to a new `GET /api/config/pre-login` (`@PermitAll`). `GET /api/config/gui` and `GET /api/config/user-system` are now `@RolesAllowed("REGULAR", "ADMIN")` and only answer authenticated traffic. On the frontend, `GuiConfigService.load()` always fetches `/config/pre-login` at `APP_INITIALIZER`. When a JWT is already in `localStorage` (browser reload while logged in), it chains `/config/gui` + `/config/user-system` in the same await so the full config is in memory before any post-login component mounts. `UserService.handleAccessToken` does the same chaining on a fresh login so `loginWithExistingToken` (which reads `config.env.inviteOnly`) runs only after the authenticated config has resolved. Expired-token 403s on the post-login fetch are caught so a stale `localStorage` token cannot block bootstrap — that was the exact failure mode that caused apache#5025 to revert the earlier eager-401 lockdown. ### Any related issues, documentation, discussions? Closes apache#5304. Related: apache#4901 (eager-401 from `JwtAuthFilter`), apache#5025 (revert that broke `ConfigService` bootstrap last time we attempted a similar lockdown), apache#5199 (re-applied `@RolesAllowed` enforcement on the microservices, with `@PermitAll` opt-out for the two pre-login endpoints). ### How was this PR tested? Added unit tests covering pre-login / gui / user-system access with and without a valid Bearer token, the orchestrator's branching on a stored token, the 403 fallback, and the `UserService.handleAccessToken` ordering guarantee. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.7 --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…che#5421) ### What changes were proposed in this PR? `LiteLLMProxyResource` (`/chat/*`) and `LiteLLMModelsResource` (`/models`) in `access-control-service` were `@PermitAll` — they contain no auth check beyond a `guiWorkflowWorkspaceCopilotEnabled` feature flag, so any anonymous caller could spend the deployment's LiteLLM credits whenever Copilot was on. PR apache#5404 left the annotations in place to preserve pre-eager-filter behavior and deferred the hardening decision; this picks it back up. Both classes now use `@RolesAllowed(Array("REGULAR", "ADMIN"))`. The JwtAuthFilter from apache#5404 runs at `Priorities.AUTHENTICATION`, so missing tokens fall to a 401 from the filter and bad-role tokens fall through to a 403 from Jersey's role check. `access-control-service` was the one microservice that hadn't picked up `RolesAllowedDynamicFeature` when apache#5199 added it elsewhere, so this PR also registers the feature in `AccessControlService.scala` — otherwise the annotations would have been decorative. `AccessControlServiceRunSpec` is updated to pin the registration so a future refactor can't quietly drop it and send us back to anonymous-LLM-access. ### Any related issues, documentation, discussions? Closes apache#5420. Follow-up hardening for apache#5404. ### How was this PR tested? `sbt AccessControlService/test` (22 cases) and `sbt scalafmtCheckAll` clean. Manual verification against a running access-control-service: anonymous `curl http://localhost:8081/api/models` returns 401 with `WWW-Authenticate: Bearer realm="texera"` instead of the pre-PR 200; a REGULAR-role bearer token gets through to LiteLLM as expected. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 4.7)
…AllowedDynamicFeature (apache#5198) ### What changes were proposed in this PR? Registers Jersey's `RolesAllowedDynamicFeature` in `file-service`'s Jersey environment so the `@RolesAllowed` / `@PermitAll` annotations already present on `DatasetResource` are actually enforced. `file-service` registered `JwtAuthFilter` (authentication) and the `AuthValueFactoryProvider.Binder` (so `@Auth user` injects), but never `RolesAllowedDynamicFeature` (authorization). The ~20 `@RolesAllowed(Array("REGULAR", "ADMIN"))` annotations on `DatasetResource` were therefore decorative: any valid JWT reached the resource method regardless of role. This adds the one missing registration. ```scala // Enforce @RolesAllowed annotations on resource methods environment.jersey.register(classOf[RolesAllowedDynamicFeature]) ``` Once enforcement is live, the six public-dataset endpoints (`getPublicPresignedUrl`, `getPublicPresignedUrlWithS3`, `getPublicDatasetVersionList`, `retrievePublicDatasetVersionRootFileNodes`, `getPublicDataset`, `getDatasetCover`) must stay reachable without a JWT for anonymous hub visitors. They are already `@PermitAll` on `main`; the new spec pins that so a future refactor cannot silently lock them out. ### Scope note This PR was originally "complete @RolesAllowed enforcement across microservices." Since then the rest of that work has landed or is in flight on `main`, so this PR has been narrowed to the one remaining gap: - `config-service`, `computing-unit-managing-service`, `workflow-compiling-service`: done in apache#5049 / apache#5199. - `JwtAuthFilter` priority + eager-401 + `@PermitAll` opt-out: done in apache#5404. - `access-control-service` (LiteLLM proxy hardening + feature registration): handled by apache#5421 (@Yicong-Huang). - **`file-service`: this PR.** With this and apache#5421, every microservice that uses `@RolesAllowed` enforces it, closing out apache#4904. ### Any related issues, documentation, or discussions? Closes apache#5433. Follow-up to apache#4904; companion to apache#5421. ### How was this PR tested? Added `DatasetResourcePermissionsSpec`, which verifies the six public-dataset endpoints carry `@PermitAll` so they remain anonymous-accessible after enforcement is enabled. `file-service` and the auth modules compile clean. Existing `DatasetResource` `@RolesAllowed` annotations are unchanged. ### Was this PR authored or co-authored using generative AI tooling? Co-authored with Claude Opus 4.8 in compliance with ASF Generative Tooling Guidance. --------- Co-authored-by: Yicong Huang <[email protected]>
…he#5743) ### What changes were proposed in this PR? - Add `RoleAnnotationEnforcer` in `common/auth`: a pure, reflection-based check whose `findUnannotatedEndpoints` flags every HTTP-mapped resource method (detected generically via the JAX-RS `@HttpMethod` meta-annotation, covering GET/POST/PUT/DELETE/PATCH/HEAD/OPTIONS and custom verbs) that lacks `@RolesAllowed`/`@PermitAll`/`@DenyAll` at either the method or its resource class. - Wire all five apache#5199 microservices (config, access-control, computing-unit-managing, workflow-compiling, file) to call `enforceRoleAnnotations(environment)` once every resource has been registered in `run()`, reading the live Jersey `ResourceConfig`; an unannotated endpoint now logs and throws `IllegalStateException` so the service fails to boot instead of exposing a silent public endpoint. - Add `RoleAnnotationEnforcerSpec` for the enforcer logic plus a per-service guard test (over each service's real registered resources) so a forgotten annotation fails in CI without needing a full boot. - Scope is the five microservices only; amber is intentionally left out because its pre-existing endpoints are not all annotated yet and would fail the check (a separate cleanup). ### Any related issues, documentation, discussions? Closes: apache#5742 ### How was this PR tested? - Run `sbt "Auth/testOnly *RoleAnnotationEnforcerSpec"`, expect 16 cases green. Coverage of `findUnannotatedEndpoints`: all-annotated passes; an unannotated `@GET` is flagged; class-level annotation covers methods; `@PermitAll`/`@DenyAll` accepted; non-HTTP methods ignored; no resources returns empty; holes across multiple resources reported as fully-qualified `Class#method`; verbs beyond GET/POST/DELETE (`@PUT`/`@PATCH`/`@HEAD`/`@OPTIONS`) detected via the `@HttpMethod` meta-annotation; a security annotation inherited from a superclass method counts as covered; a subclass class-level annotation covers an inherited endpoint; an inherited unannotated endpoint is flagged against the scanned subclass; duplicate resources are de-duplicated. Coverage of `enforce`: throws (message names the service and offending method, and lists every offender) and does not throw on clean input or empty input. Verified locally. - Run `sbt "ConfigService/testOnly *ConfigServiceRunSpec"` (and the equivalent `AccessControlService`/`ComputingUnitManagingService`/`WorkflowCompilingService`/`FileService` RunSpecs); expect the new "registered resources should all declare access control" guard to pass, confirming each service's real endpoints are fully annotated. - Reviewer check for the regression: drop a new `@GET` with no role annotation onto any wired resource and start the service (or run that service's RunSpec); expect an `IllegalStateException` naming `Class#method` and a failed boot. - Local environment limitation: this machine runs JDK 25, where the repo's existing Mockito `*RunSpec` cases cannot mock `JerseyEnvironment` and file-service tests hit a JaCoCo 0.8.11 instrumentation crash on an unrelated class; these are pre-existing toolchain issues (baseline fails identically) and run on CI's supported JDK. The new non-mock guard tests were verified locally for config/access-control/computing-unit-managing/workflow-compiling. ### Was this PR authored or co-authored using generative AI tooling? Co-authored with Claude Opus 4.8 in compliance with ASF --------- Signed-off-by: Matthew B. <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]>
apache#9079) ### What changes were proposed in this PR? `compileWorkflowAsync` called the JWT-protected `/api/compile` (`@RolesAllowed(REGULAR, ADMIN)` behind `JwtAuthFilter`, since apache#5199 / apache#5404) with only `Content-Type`, so every agent compile returned 401. The agent silently proceeded without operator output schemas or compile errors. ``` Before: prepareStep -> POST /api/compile (no Authorization) -> 401 -> null After: prepareStep -> POST /api/compile (Bearer <delegate token>) -> 200 -> schemas + operatorErrors ``` | File | Change | | --- | --- | | `api/compile-api.ts` | optional `token` param; sends `createAuthHeaders(token)` when present (no-token behavior unchanged) | | `agent/texera-agent.ts` | `prepareStep` passes `this.delegateConfig?.userToken` | Audited the other agent-service HTTP calls: workflow persist/retrieve and execution already send the Bearer token; `/api/resources/operator-metadata` is public. Compile was the only gap. ### Any related issues, documentation, discussions? Closes apache#9078 ### How was this PR tested? Regression tests written first (failed before the fix, pass after): - `compile-api.spec.ts`: sends `Authorization: Bearer <token>` when given; omits it for an empty token; against a mock that mirrors `JwtAuthFilter` (401 without Bearer, 200 with), returns `null` without a token and the schemas with one. - `texera-agent.spec.ts`: in delegate mode, every compile request carries `Bearer <delegate token>`. ``` cd agent-service bun test # 314 pass, 0 fail (19 files) bun run typecheck # tsc --noEmit, exit 0 bun run format:check # All matched files use Prettier code style! ``` Verified end-to-end against a running cluster. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
What changes were proposed in this PR?
Re-applies #5049 (Jersey
@RolesAllowedenforcement onconfig-service,computing-unit-managing-service, andworkflow-compiling-service) and additionally marks the two pre-loginConfigResourceendpoints —/api/config/guiand/api/config/user-system— as@PermitAll. Those endpoints are loaded byGuiConfigService.load()in the AngularAPP_INITIALIZERbefore any login, so once role enforcement is on they must keep returning200to unauthenticated callers; missing this was what broke bootstrap and got #5049 reverted in #5173. Everything outsideconfig-servicematches #5049 byte-for-byte.Any related issues, documentation, or discussions?
Closes: #4904
Prior attempt: #5049, reverted by #5173. The bootstrap root cause was diagnosed inline at #5049 (comment).
How was this PR tested?
Added
ConfigResourceAuthSpec: wiresConfigResourcethrough the sameJwtAuthFilter+RolesAllowedDynamicFeaturepipeline production uses (via Dropwizard'sResourceExtension) and fires HTTP requests with noAuthorizationheader.GET /config/gui→ expects200GET /config/user-system→ expects200GET /auth-probe(an in-test@RolesAllowedresource) → expects403Manually tested. The
403sanity guard ensures the feature is actually enforcing, so a future "200 everywhere" regression cannot silently slip through. Kept the three*ServiceRunSpecstructural tests from #5049 verifying thatRolesAllowedDynamicFeatureis registered. Manual reproduction withcurlagainst a local dev server confirmed the unauthenticated bootstrap path returns200while a low-role JWT against an annotated endpoint returns403.Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.7 in compliance with ASF.