Skip to content

fix(amber, v1.2): require auth on retrieveWorkflowRuntimeStatistics - #7054

Merged
Yicong-Huang merged 2 commits into
release/v1.2from
backport/7014-require-auth-on-retrieveworkflowruntimes-v1.2
Jul 30, 2026
Merged

fix(amber, v1.2): require auth on retrieveWorkflowRuntimeStatistics#7054
Yicong-Huang merged 2 commits into
release/v1.2from
backport/7014-require-auth-on-retrieveworkflowruntimes-v1.2

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Automated backport of #7014 to release/v1.2.

Source: 0635737 · automation run

Any related issues, documentation, discussions?

Backport of #7014. Originally linked #6977.

How was this PR tested?

Release-branch CI runs on this branch once the build is fixed and this PR is marked ready for review.

Was this PR authored or co-authored using generative AI tooling?

No.

### What changes were proposed in this PR?

`retrieveWorkflowRuntimeStatistics` (`GET
/executions/{wid}/stats/{eid}`) was the only endpoint in
`WorkflowExecutionsResource` declaring neither `@RolesAllowed` nor an
`@Auth` parameter — every other handler in the class carries
`@RolesAllowed(Array("REGULAR", "ADMIN"))` + `@Auth sessionUser`, and
there is no class-level annotation to fall back on. Auth is enforced
per-method via `RolesAllowedDynamicFeature`, so this one handler was
reachable without authentication.

- Add `@RolesAllowed(Array("REGULAR", "ADMIN"))` and an `@Auth
sessionUser: SessionUser` parameter, matching the sibling endpoints
exactly.
- Add an **auth-annotation audit test** to
`WorkflowExecutionsResourceSpec`: it reflects over every
`@GET/@PUT/@POST/@DELETE` handler in the class and asserts each declares
`@RolesAllowed` and takes an `@Auth` parameter — so any future endpoint
added without auth turns the suite red instead of shipping unprotected.
`exportResultToLocal` is explicitly exempted with a comment: it serves a
browser form-submit download (which can't carry an `Authorization`
header), so its JWT arrives as a form field and is verified in-method
via `JwtParser.parseToken`, including the role check.

The frontend is unaffected: `JwtModule` attaches the `Authorization`
header to every request (`app.module.ts`), and the same service already
calls sibling endpoints that require auth.

### Any related issues, documentation, discussions?

Closes #6977.

### How was this PR tested?

- The audit test **fails before the fix**, naming exactly
`retrieveWorkflowRuntimeStatistics` as the offender, and passes after —
the failing run is the repro for the issue. (Its first run also flagged
`exportResultToLocal`; on inspection that endpoint authenticates
manually by design — see above — which is why the exemption is explicit
and documented rather than silent.)
- Full `WorkflowExecutionsResourceSpec` run locally: all tests pass;
`WorkflowExecutionService/scalafmtCheck` (main + Test) passes.
- Verified no other caller of the method exists (the added parameter
breaks no call site), and that all sibling endpoints use the identical
annotation pattern being applied here.

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (claude-opus-4-8)

---------

(backported from commit 0635737)

Signed-off-by: Xinyuan Lin <xinyual3@uci.edu>
Co-authored-by: Xinyuan Lin <xinyual3@uci.edu>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor Author

The cherry-pick applied cleanly but the backported tree failed its pre-merge build. Fix the build on this branch, then mark this PR ready for review.

Copilot AI 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.

Pull request overview

Backports the security fix from #7014 onto release/v1.2 by ensuring WorkflowExecutionsResource.retrieveWorkflowRuntimeStatistics is protected by the same declarative authentication/authorization pattern used by the rest of the resource, and adds a regression-style audit test to prevent future unauthenticated endpoints from being introduced.

Changes:

  • Require @RolesAllowed(Array("REGULAR", "ADMIN")) and an @Auth sessionUser parameter on GET /executions/{wid}/stats/{eid}.
  • Add an auth-annotation audit test that reflects over WorkflowExecutionsResource HTTP handlers and asserts each declares @RolesAllowed and accepts an @Auth parameter (with an explicit exemption for exportResultToLocal, which authenticates manually).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResource.scala Secures retrieveWorkflowRuntimeStatistics with roles + injected auth user, and enforces workflow access check before returning runtime stats.
amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowExecutionsResourceSpec.scala Adds a reflection-based audit test to ensure all HTTP endpoints in WorkflowExecutionsResource declare @RolesAllowed and take an @Auth parameter (excluding the known manual-auth download endpoint).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mengw15 mengw15 added the engine label Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @seongjinyoon, @Yicong-Huang
    You can notify them by mentioning @seongjinyoon, @Yicong-Huang in a comment.

@codecov-commenter

codecov-commenter commented Jul 30, 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.48%. Comparing base (29c3469) to head (d54d646).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ard/user/workflow/WorkflowExecutionsResource.scala 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             release/v1.2    #7054      +/-   ##
==================================================
- Coverage           52.49%   52.48%   -0.02%     
+ Complexity           2498     2494       -4     
==================================================
  Files                1077     1077              
  Lines               42296    42297       +1     
  Branches             4551     4551              
==================================================
- Hits                22203    22198       -5     
- Misses              18782    18787       +5     
- Partials             1311     1312       +1     
Flag Coverage Δ *Carryforward flag
access-control-service 64.35% <ø> (ø) Carriedforward from 29c3469
agent-service 34.36% <ø> (ø) Carriedforward from 29c3469
amber 52.51% <0.00%> (-0.04%) ⬇️
computing-unit-managing-service 1.65% <ø> (ø) Carriedforward from 29c3469
config-service 56.06% <ø> (ø) Carriedforward from 29c3469
file-service 60.53% <ø> (ø) Carriedforward from 29c3469
frontend 47.32% <ø> (ø) Carriedforward from 29c3469
pyamber 90.97% <ø> (ø) Carriedforward from 29c3469
python 90.80% <ø> (ø) Carriedforward from 29c3469
workflow-compiling-service 58.69% <ø> (ø) Carriedforward from 29c3469

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

@Yicong-Huang

Copy link
Copy Markdown
Contributor

@xuang7 PTAL

@Yicong-Huang
Yicong-Huang added this pull request to the merge queue Jul 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to Branch Protection failures Jul 30, 2026
You're not authorized to push to this branch. Visit "About protected branches" for more information.
@Yicong-Huang
Yicong-Huang added this pull request to the merge queue Jul 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 30, 2026
@Yicong-Huang
Yicong-Huang added this pull request to the merge queue Jul 30, 2026
Merged via the queue into release/v1.2 with commit b1ac819 Jul 30, 2026
33 of 37 checks passed
@Yicong-Huang
Yicong-Huang deleted the backport/7014-require-auth-on-retrieveworkflowruntimes-v1.2 branch July 30, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants