Skip to content

feat(chart): authorise users by a claim - #268

Merged
uniqueg merged 5 commits into
devfrom
feat/chart-auth-claim
Nov 7, 2026
Merged

uniqueg merged 5 commits into
devfrom
feat/chart-auth-claim

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Exposes tesk-api's authorisation without groups (elixir-cloud-aai/tesk-api#78, PR 116) as chart values under auth. It is off by default.

  • auth.claim.enabled (false), auth.claim.name and auth.claim.values (a list) are passed on as TESK_API_AUTHORISATION_CLAIM_ENABLED, _NAME and _VALUES. The values are trimmed, blank ones are left out, and the rest are joined with commas.
  • The variables are rendered only when the setting is on and auth.mode is auth. With noauth, all endpoints are open and tesk-api doesn't read them.
  • Turned on without a name or a non-blank value, the chart fails, since tesk-api would stop at startup. The schema rejects values with commas, because tesk-api would split them, and unknown keys under auth.claim.
  • Docs:
    • docs/configuration.md: the values.
    • docs/deployment.md: new section "Authorisation by a claim", with an example, the rules, the security implications and a pointer to tesk-api's docs/access-control.md.
    • docs/upgrading.md: a note next to the other tesk-api 1.2.0 values.
  • Needs tesk-api 1.2.0 or later. The chart's default image (appVersion 1.1.0) doesn't know these settings yet; the docs say so, as they do for auth.serviceInfoPublic.

Closes #265

Verification

  • REQUIRE_HELM=1 pytest -q (helm v3.22.1): 329 passed. The tests were written first and failed before the change. They cover the off cases (rendered with mode auth), mode noauth, the passed values, trimming, blank values, incomplete settings, and schema rejections.

  • helm lint charts/tesk --strict, ruff check and ruff format --check (0.17.3), mypy tests, mkdocs build --strict: all clean.

  • Reviews: two rounds of the adversarial and quality reviewers. I fixed all medium findings and the cheap or behavioural low ones (mode gate, blank values that the schema pattern lets through, test gaps, placement of the upgrade note, wrapping).

  • CI: all checks passed on 4ec7096 (Chart install, Docs, Lint, Test, CodeQL). The branch merges cleanly with dev after feat(chart): set the executors' security context #266.

  • Sourcery: 1 thread (the tests always expected the same claim name), fixed in ec87525 and resolved. Branch updated with dev; CI green on e748c9d.

Declined review findings

  • A combined auth.mode such as auth,debug gets no claim variables. This is consistent with the chart's existing exact match on auth (e.g., the OAuth client secret), and it fails closed, granting no access. Restricting auth.mode to auth or noauth would affect existing values, so it belongs in its own issue.
  • Bumping appVersion to tesk-api 1.2.0: this belongs to the release-prep PR, once tesk-api 1.2.0 is released.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 3 commits November 7, 2026 22:26
Add the values auth.claim.enabled (false), auth.claim.name and
auth.claim.values, which pass tesk-api's authorisation without groups
on (TESK_API_AUTHORISATION_CLAIM_ENABLED, _NAME and _VALUES, the
values joined with commas). Off by default, which renders none of the
variables.

Turned on without a name or a non-blank value, the chart fails, as
tesk-api would stop at startup; the schema rejects values with commas,
which tesk-api would split. The deployment guide explains the setting
and its security implications, with a pointer to tesk-api's
docs/access-control.md.

Closes #265

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Pass the claim on only with mode auth: with noauth, all endpoints
  are open and tesk-api doesn't check it.
- Leave out values that are blank after trimming (e.g. a vertical tab
  or a no-break space, which the schema's pattern lets through), so
  the chart fails instead of tesk-api; convert values to strings
  before trimming.
- Test trimming, blank values and mode noauth; move the upgrade note
  next to the other tesk-api 1.2.0 values; rewrap the docs link.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Render the off cases with mode auth, so that they test the enabled
check rather than the mode gate; reflow the values comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Configuration

Add and validate the claim authorisation settings, then render tesk-api environment variables only when claim authorisation is enabled in auth mode.

  • charts/tesk/templates/common/tesk-deployment.yaml L107-129
  • charts/tesk/values.schema.json L280-317
  • charts/tesk/values.yaml L143-157

Documentation

Explain how to configure claim-based authorisation, its security implications and version requirement, and record the setting in the configuration and upgrade guides.

  • docs/configuration.md L111-113
  • docs/deployment.md L242-275
  • docs/upgrading.md L318-325

Tests

Test that claim settings are omitted when disabled or in noauth mode, rendered and trimmed when enabled, and rejected when incomplete or invalid.

  • tests/test_chart.py L705-842

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 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (918fe7b) to head (e748c9d).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #268   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          229       229           
=========================================
  Hits           229       229           

☔ 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 7, 2026 21:45

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 issue

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

## Individual Comments

### Comment 1
<location path="tests/test_chart.py" line_range="635" />
<code_context>
+    """
+    variables = env(render("--set", "auth.mode=auth", *args))
+    assert variables["TESK_API_AUTHORISATION_CLAIM_ENABLED"] == "true"
+    assert variables["TESK_API_AUTHORISATION_CLAIM_NAME"] == "eduperson_entitlement"
+    assert variables["TESK_API_AUTHORISATION_CLAIM_VALUES"] == values
+
</code_context>
<issue_to_address>
**Hardcoded claim name passes**

When the chart always renders `eduperson_entitlement` as the claim name, `test_auth_claim` asserts that the rendered name is `eduperson_entitlement`, so a chart that ignores `auth.claim.name` and always renders that value still passes. Every case supplies that same effective name.

Add a successful case with a different configured name and assert that name is rendered.
</issue_to_address>

Linked issues

#265 feat(chart): authorise by a claim of the user info · 4 of 4 met

# Requirement Status Notes
1 Off by default, which renders the same objects as before. ✅ Met auth.claim.enabled defaults to false, and the claim variables are omitted unless enabled.
2 Expose auth.claim values and pass the three variables when enabled. ✅ Met The deployment template passes the enabled flag, claim name, and comma-joined values; tests cover the enabled case.
3 Fail at render time when enabled without a name or values, and validate claim values in the schema. ✅ Met The template fails for missing or blank names and values; the schema rejects comma-containing values and unknown auth.claim keys.
4 Document the values and setup, with a pointer to tesk-api access-control docs and the supporting version. ✅ Met The configuration reference and deployment guide cover the setting, and the deployment guide links to tesk-api docs and states the 1.2.0 requirement.

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and with claim authorisation enabled, anyone whose user info contains a configured value can create tasks without group membership, including running arbitrary images and commands. Reverting removes that access path, but cannot undo workloads already run or data already exposed.

Blocking findings: tests/test_chart.py:635


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

Comment thread tests/test_chart.py Resolved
@uniqueg
uniqueg merged commit 438b40d into dev Nov 7, 2026
28 checks passed
@uniqueg
uniqueg deleted the feat/chart-auth-claim branch November 7, 2026 22:02
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.

feat(chart): authorise by a claim of the user info

1 participant