Repository navigation
feat(chart): authorise users by a claim - #268
Conversation
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]>
Reviewer's GuideConfigurationAdd and validate the claim authorisation settings, then render tesk-api environment variables only when claim authorisation is enabled in auth mode.
DocumentationExplain how to configure claim-based authorisation, its security implications and version requirement, and record the setting in the configuration and upgrade guides.
TestsTest that claim settings are omitted when disabled or in noauth mode, rendered and trimmed when enabled, and rejected when incomplete or invalid.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.nameandauth.claim.values(a list) are passed on asTESK_API_AUTHORISATION_CLAIM_ENABLED,_NAMEand_VALUES. The values are trimmed, blank ones are left out, and the rest are joined with commas.auth.modeisauth. Withnoauth, all endpoints are open and tesk-api doesn't read them.auth.claim.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'sdocs/access-control.md.docs/upgrading.md: a note next to the other tesk-api 1.2.0 values.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 checkandruff 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
auth.modesuch asauth,debuggets no claim variables. This is consistent with the chart's existing exact match onauth(e.g., the OAuth client secret), and it fails closed, granting no access. Restrictingauth.modetoauthornoauthwould affect existing values, so it belongs in its own issue.appVersionto 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