Skip to content

feat!: show tasks to their owner only - #219

Merged
uniqueg merged 5 commits into
devfrom
feat/218-owner-only-tasks
Nov 23, 2026
Merged

uniqueg merged 5 commits into
devfrom
feat/218-owner-only-tasks

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds TESK_API_AUTHORISATION_TASK_VISIBILITY (tesk.api.authorisation.task-visibility), following elixir-cloud-aai/generic-issues#124:

  • owner (default, secure by default): users get, list and cancel only their own tasks, whatever their groups; super admins and team admins included. Groups still decide who may create tasks. Owner-only narrows the existing rules down to the creator's tasks: getTask (and so cancel, which gets the task first) additionally requires the creator (the rule moved from the @PostAuthorize SpEL into the unit-tested User#mayGet); lists always select by the creator hash and filter by the creator annotation, also for admins and with legacy labels.
  • group: the previous behaviour (team admins see their teams' tasks, super admins all tasks).
  • Values bind in any case; empty keeps owner; invalid values stop the app at startup. Service clients follow the setting too (no change in effect). No effect with noauth.
  • Breaking change of the default for installations that rely on admins seeing other users' tasks; the upgrade notes say how to keep it (group).
  • One deliberate difference: a task log without any metadata now gives non-admins 403 instead of a 500 from the SpEL (TESK never creates such tasks).

Docs: access control (new "Task visibility" section; admin rules and examples marked as group), configuration reference, upgrade notes of 2.1.0 (behaviour change, how to keep the old behaviour).

Closes #218

Verification

  • ./mvnw -B clean verify (JDK 21 container): 18732 unit tests and 153 ITs pass, JaCoCo check passes.
  • ./mvnw -B spotless:check checkstyle:check: pass.
  • mkdocs build --strict: pass.
  • New TaskVisibilityOwnerAuthIT (default owner): super admin and team admin get 403 on another user's task (grouped and ungrouped), cannot cancel it, and list only their own tasks (the selector names the creator); owners (member, team admin, super admin) keep access. AuthIT, ClaimAuthIT and ServiceClientAuthIT pin group and pass unchanged. Unit tests in UserTest (incl. mayGet with legacy labels, service clients, missing metadata), ElixirPrincipalExtractorTest, ClaimAuthorisationTest, ServiceClientTokenServicesTest, KubernetesClientWrapperTest (owner-only admin list with legacy labels) and TaskVisibilitySettingTest (binding) cover both modes.
  • CI: all checks pass (CI passed, Test, Lint, Docs, Smoke test, Scan image, CodeQL, codecov).

Follow-up

The TESK Helm chart can't pass the variable today (no extraEnv); a chart issue is drafted.

Declined review findings

  • Extract a shared base class for the WireMock setup of the auth ITs (quality reviewer, low): the new IT follows the existing pattern; a refactor of all ITs is out of scope here.
  • Let owners keep access to their tasks whatever their current groups (Sourcery, medium): that would widen access for users who left a team; owner-only only narrows the existing rules, as decided in Tasks visible to their owner only #218.

🤖 Generated with Claude Code

https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5

uniqueg and others added 4 commits November 23, 2026 04:29
Add tesk.api.authorisation.task-visibility
(TESK_API_AUTHORISATION_TASK_VISIBILITY): with `owner`, the default, users get, list and cancel
only their own tasks, whatever their groups; super admins and team
admins included. `group` keeps the previous behaviour, in which team
admins see all tasks of their teams and super admins all tasks.

Owner-only visibility narrows the existing rules down to the creator's
tasks: getTask additionally requires the creator, and lists always
select and filter by the creator, also for admins and with legacy
labels. Users without authentication (noauth) are unaffected.

AuthIT, ClaimAuthIT and ServiceClientAuthIT pin `group`; the new
TaskVisibilityOwnerAuthIT covers the default.

Closes #218

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Describe TESK_API_AUTHORISATION_TASK_VISIBILITY in the access control
guide and the configuration reference, mark the admin rules and
examples as those of `group` visibility, and add the behaviour change
to the upgrade notes of 2.1.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Move the rule of getTask from the SpEL of @PostAuthorize into
User#mayGet, which is unit-tested in both visibility modes. Service
clients now follow the task visibility too (no change in effect: they
have no groups). Add tests for the binding of the setting (default,
case, empty and invalid values) and for an admin's owner-only list with
legacy labels, and fix review findings in the docs and Javadoc.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Test User#mayGet with tasks with only the old creator label, service
clients and logs without metadata, and mark the permission table of the
access control guide as that of `group` visibility.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
@uniqueg uniqueg self-assigned this Nov 23, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Add the ownerOnly state to User and carry it through construction, equality, hashing, and the builder so authorization logic can distinguish visibility modes.

  • src/main/java/uk/ac/ebi/tsc/tesk/config/security/User.java L63-69, L115-118, L507-511 (+7 small edits)

Implementation

Centralize get authorization in User#mayGet and make owner-only mode constrain both task retrieval and listing, including lists that require post-filtering.

  • src/main/java/uk/ac/ebi/tsc/tesk/config/security/User.java L148-166, L195-210, L236-256 (+1 small edits)
  • src/main/java/uk/ac/ebi/tsc/tesk/k8s/service/KubernetesClientWrapper.java L32 (removed lines), L280-287
  • src/main/java/uk/ac/ebi/tsc/tesk/tes/service/TesService.java L34-36, L42

Pass the configured visibility mode into authenticated principals and service-client principals so the same task rules apply to both.

  • src/main/java/uk/ac/ebi/tsc/tesk/config/security/ElixirPrincipalExtractor.java L163
  • src/main/java/uk/ac/ebi/tsc/tesk/config/security/ServiceClientTokenServices.java L98-101 (+4 small edits)

Configuration

Introduce the owner/group visibility setting, default it to OWNER, and expose it through application configuration.

  • src/main/java/uk/ac/ebi/tsc/tesk/config/security/AuthorisationProperties.java L55-60, L229-236
  • src/main/java/uk/ac/ebi/tsc/tesk/config/security/TaskVisibility.java L1-19
  • src/main/resources/application.properties L70-73

Documentation

Explain the visibility modes, their endpoint and legacy-task effects, the configuration setting, and the upgrade impact of the new default.

  • docs/access-control.md L85-123, L140-146, L255-258 (+2 small edits)
  • docs/configuration.md L39-40
  • docs/upgrading.md L5-22, L323-324

Tests

Cover owner-only access and list results in integration tests while pinning existing authorization suites to group visibility.

  • src/integration-test/java/uk/ac/ebi/tsc/tesk/AuthIT.java L36-38, L48-49
  • src/integration-test/java/uk/ac/ebi/tsc/tesk/ClaimAuthIT.java L42-43
  • src/integration-test/java/uk/ac/ebi/tsc/tesk/ServiceClientAuthIT.java L55-56
  • src/integration-test/java/uk/ac/ebi/tsc/tesk/TaskVisibilityOwnerAuthIT.java L1-225

Test visibility-setting binding, principal propagation, authorization decisions, list filtering, and legacy-label behavior across the two modes.

  • src/test/java/uk/ac/ebi/tsc/tesk/config/security/ClaimAuthorisationTest.java L162-175
  • src/test/java/uk/ac/ebi/tsc/tesk/config/security/ElixirPrincipalExtractorTest.java L228-250 (+3 small edits)
  • src/test/java/uk/ac/ebi/tsc/tesk/config/security/ServiceClientTokenServicesTest.java L671-678
  • src/test/java/uk/ac/ebi/tsc/tesk/config/security/TaskVisibilitySettingTest.java L1-59
  • src/test/java/uk/ac/ebi/tsc/tesk/config/security/UserTest.java L5-16, L80-253 (+2 small edits)
  • src/test/java/uk/ac/ebi/tsc/tesk/k8s/service/KubernetesClientWrapperTest.java L42, L372-412

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (82ab28c) to head (2019354).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #219   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           55        56    +1     
  Lines         2515      2543   +28     
  Branches       287       296    +9     
=========================================
+ Hits          2515      2543   +28     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 23, 2026 04:40
@sourcery-ai

sourcery-ai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit 2019354

#218 Tasks visible to their owner only · 4 of 6 met

# Requirement Status Notes
1 Add owner and group task visibility modes, with owner as the default. ✅ Met The new setting defaults to OWNER, supports GROUP, and is wired into user and service-client authorization.
2 With owner, users get, list and cancel only their own tasks, whatever their groups; owners keep full access. 🟡 Partly met Other users' tasks are denied or filtered out, but the existing group-membership rules still prevent some owners from accessing their own tasks.
3 With group, retain the previous behavior. ✅ Met The existing authorization integration tests pin group visibility and cover the previous behavior.
4 Unit tests and AuthIT cover both visibility modes. ✅ Met Unit tests cover both modes; AuthIT exercises group visibility and the new TaskVisibilityOwnerAuthIT exercises the default owner mode.
5 Update docs/access-control.md, the configuration reference and docs/upgrading.md. ✅ Met All three documents describe the setting and its behavior.
6 The TESK chart can set the visibility value. ❌ Not addressed The PR says the Helm chart cannot set the value yet and defers chart support to a follow-up.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/main/resources/application.properties" line_range="73" />
<code_context>
+#which tasks users may get, list and cancel: only their own, whatever their groups, admins included (owner,
+#the default), or as their groups decide, team admins all tasks of their teams, super admins all tasks (group;
+#see docs/access-control.md)
+tesk.api.authorisation.task-visibility=owner
 #server.port=8082

</code_context>
<issue_to_address>
**Old replicas still expose other users’ tasks**

When an authenticated deployment rolls out this version while older replicas are still serving requests, the older replicas keep the previous group-based authorization, so requests routed to them still let team and super admins get or cancel other users’ tasks and list those tasks. The owner-only policy is therefore not enforced consistently until those replicas are drained.

Drain or otherwise stop routing requests to old replicas before treating owner-only visibility as enforced.
</issue_to_address>

### Comment 2
<location path="src/integration-test/java/uk/ac/ebi/tsc/tesk/TaskVisibilityOwnerAuthIT.java" line_range="219" />
<code_context>
+            this.mvc
+                    .perform(get(TASK_URL + "?view=" + view).header("Authorization", "Bearer BAR"))
+                    .andExpect(status().isOk())
+                    .andExpect(jsonPath("$.tasks.length()").value(expectedLength));
+        }
+    }
</code_context>
<issue_to_address>
**Wrong tasks can pass list tests**

When the API returns two non-owner tasks instead of the two expected owner tasks, `superAdmin_listsOwnTasksOnly` and `teamAdmin_listsOwnTasksOfTheTeamOnly` both pass if the API returns any two tasks, including other users' tasks, because `performListTask` checks only the array length. The tests therefore pass without verifying owner-only visibility.

Assert the returned task IDs (or creators) as well as the list length.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and with the default owner setting, admins can no longer get, list, or cancel other users’ tasks through the API; if that access policy is wrong, operators may silently lose their expected management workflow. Reverting or setting visibility to group restores the previous access, but this is a permission default that takes effect for everyone on deployment.

Blocking findings: src/main/resources/application.properties:73, src/integration-test/java/uk/ac/ebi/tsc/tesk/TaskVisibilityOwnerAuthIT.java:219


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Check which tasks the owner-only list tests return, not only how many,
and note in the upgrade notes that old pods keep the old rules until a
rolling update has completed (Sourcery review).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New gaps against the linked issues

@uniqueg
uniqueg merged commit b101f7b into dev Nov 23, 2026
34 checks passed
@uniqueg
uniqueg deleted the feat/218-owner-only-tasks branch November 23, 2026 05:06
uniqueg added a commit that referenced this pull request Nov 23, 2026
Set date-released to 2026-11-24, the planned tag day, and add the
changes merged since the first prep commit to the curated notes:
owner-only task visibility (#218, #219), team names in labels
(#216, #217) and audiences per service client (#215, #220; #220 is
expected to merge before the tag); the merge of dev put them into the
upgrade intro. The notes link the upgrade notes of the v2.1.0 tag,
which never move, instead of the latest docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tasks visible to their owner only

1 participant