Skip to content

fix: enforce @RolesAllowed on microservice resources - #5199

Merged
Yicong-Huang merged 9 commits into
apache:mainfrom
Yicong-Huang:fix/roles-allowed-redo
May 31, 2026
Merged

Yicong-Huang merged 9 commits into
apache:mainfrom
Yicong-Huang:fix/roles-allowed-redo

Conversation

@Yicong-Huang

@Yicong-Huang Yicong-Huang commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Re-applies #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 #5049 reverted in #5173. Everything outside config-service matches #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: 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 #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.

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]>
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file fix common platform Non-amber Scala service paths labels May 25, 2026
@codecov-commenter

codecov-commenter commented May 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.63%. Comparing base (1b0ec78) to head (9569623).

Files with missing lines Patch % Lines
.../texera/service/ComputingUnitManagingService.scala 44.44% 5 Missing ⚠️
...ache/texera/service/WorkflowCompilingService.scala 66.66% 2 Missing ⚠️
...cala/org/apache/texera/service/ConfigService.scala 80.00% 1 Missing ⚠️
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     
Flag Coverage Δ *Carryforward flag
access-control-service 41.89% <ø> (ø)
agent-service 33.76% <ø> (ø) Carriedforward from 41fcd43
amber 51.96% <ø> (-0.05%) ⬇️
computing-unit-managing-service 1.38% <44.44%> (+1.38%) ⬆️
config-service 53.96% <80.00%> (+53.96%) ⬆️
file-service 38.42% <ø> (ø)
frontend 41.67% <ø> (-0.56%) ⬇️ Carriedforward from 41fcd43
python 90.80% <ø> (ø) Carriedforward from 41fcd43
workflow-compiling-service 58.39% <66.66%> (+1.57%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ma77Ball

Ma77Ball commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

@Yicong-Huang I raised a similar pr to fix this. #5198

@Yicong-Huang

Copy link
Copy Markdown
Contributor Author

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

@Ma77Ball

Copy link
Copy Markdown
Contributor

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

@carloea2

carloea2 commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Shouldn’t Matthew’s PR have priority?

Also this PR is bigger

@Ma77Ball

Ma77Ball commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

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.

@Yicong-Huang

Copy link
Copy Markdown
Contributor Author

@Ma77Ball can we prioritize this PR? could you help verify if the changes are enough?

@Ma77Ball Ma77Ball left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. I confirmed that all the services look and work well. I did leave a couple of minor comments/suggestions.

Yicong-Huang and others added 4 commits May 30, 2026 00:53
…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]>
@Yicong-Huang

Copy link
Copy Markdown
Contributor Author

Overall LGTM. I confirmed that all the services look and work well. I did leave a couple of minor comments/suggestions.

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().
@Yicong-Huang

Copy link
Copy Markdown
Contributor Author

@aglinxinyuan @bobbai00 can you also help review this one?

@aglinxinyuan

Copy link
Copy Markdown
Contributor

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
Yicong-Huang enabled auto-merge May 31, 2026 22:59
@bobbai00

Copy link
Copy Markdown
Contributor

@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.
@Yicong-Huang
Yicong-Huang added this pull request to the merge queue May 31, 2026
Merged via the queue into apache:main with commit 2ebef32 May 31, 2026
18 checks passed
@Yicong-Huang
Yicong-Huang deleted the fix/roles-allowed-redo branch May 31, 2026 23:58
bobbai00 pushed a commit to bobbai00/texera that referenced this pull request Jun 1, 2026
…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]>
Yicong-Huang added a commit that referenced this pull request Jun 7, 2026
### 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)
Yicong-Huang added a commit to Ma77Ball/texera that referenced this pull request Jun 7, 2026
…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)
Yicong-Huang added a commit that referenced this pull request Jun 9, 2026
…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]>
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 9, 2026
…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]>
ELin2025 pushed a commit to ELin2025/texera that referenced this pull request Jun 16, 2026
…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)
ELin2025 pushed a commit to ELin2025/texera that referenced this pull request Jun 16, 2026
…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]>
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
### 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]>
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
…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]>
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
…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)
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
…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]>
PG1204 pushed a commit to PG1204/texera that referenced this pull request Jun 25, 2026
…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]>
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 2, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common dependencies Pull requests that update a dependency file fix platform Non-amber Scala service paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Authorization bypass: @RolesAllowed unenforced on microservices, workflow-compiling-service requires no token at all

6 participants