Skip to content

fix(auth): enforce @RolesAllowed in file-service by registering RolesAllowedDynamicFeature - #5198

Merged
Yicong-Huang merged 47 commits into
apache:mainfrom
Ma77Ball:fix/RolesAllowedUnenforced
Jun 9, 2026
Merged

Yicong-Huang merged 47 commits into
apache:mainfrom
Ma77Ball:fix/RolesAllowedUnenforced

Conversation

@Ma77Ball

@Ma77Ball Ma77Ball commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

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.

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

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.

Ma77Ball added 22 commits May 12, 2026 23:08
@github-actions github-actions Bot added engine 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 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 52.32%. Comparing base (ad10b7f) to head (3cdafd3).

Files with missing lines Patch % Lines
.../scala/org/apache/texera/service/FileService.scala 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #5198   +/-   ##
=========================================
  Coverage     52.32%   52.32%           
- Complexity     2484     2485    +1     
=========================================
  Files          1068     1068           
  Lines         41353    41357    +4     
  Branches       4441     4441           
=========================================
+ Hits          21639    21642    +3     
- Misses        18444    18445    +1     
  Partials       1270     1270           
Flag Coverage Δ *Carryforward flag
access-control-service 64.61% <ø> (ø)
agent-service 33.76% <ø> (ø) Carriedforward from ad10b7f
amber 53.30% <ø> (ø) Carriedforward from ad10b7f
computing-unit-managing-service 1.65% <ø> (ø)
config-service 57.97% <ø> (+1.91%) ⬆️
file-service 38.21% <0.00%> (-0.11%) ⬇️
frontend 46.76% <ø> (ø) Carriedforward from ad10b7f
pyamber 90.72% <ø> (ø) Carriedforward from ad10b7f
python 90.75% <ø> (ø) Carriedforward from ad10b7f
workflow-compiling-service 58.69% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

@github-actions github-actions Bot removed the common label Jun 7, 2026
@Yicong-Huang

Copy link
Copy Markdown
Contributor

I suggest we backport this as well

cc @xuang7

@Yicong-Huang Yicong-Huang added the release/v1.2 back porting to release/v1.2 label Jun 7, 2026
@Yicong-Huang
Yicong-Huang requested a review from xuang7 June 7, 2026 02:10

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

Backport LGTM!

@Yicong-Huang
Yicong-Huang added this pull request to the merge queue Jun 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 7, 2026
@Yicong-Huang
Yicong-Huang added this pull request to the merge queue Jun 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 7, 2026
@Yicong-Huang
Yicong-Huang enabled auto-merge June 7, 2026 19:38
@Yicong-Huang
Yicong-Huang added this pull request to the merge queue Jun 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 7, 2026
@Ma77Ball

Ma77Ball commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

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

@Yicong-Huang
Yicong-Huang added this pull request to the merge queue Jun 9, 2026
Merged via the queue into apache:main with commit 7b7a5c6 Jun 9, 2026
28 checks passed
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]>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Backport to release/v1.2 succeeded as 7dc17c0. Run

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
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix platform Non-amber Scala service paths release/v1.2 back porting to release/v1.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Authorization bypass: @RolesAllowed unenforced on file-service (DatasetResource)

4 participants