Repository navigation
feat(chart)!: audiences per token client - #338
Conversation
auth.tokenClients.clients is now a map from client ID to the client's settings, audiences or allowAnyAudience: true (not both), and the chart passes them on to tesk-api as one JSON variable, TESK_API_AUTHORISATION_SERVICE_CLIENTS_CLIENTS (tesk-api#215, #220). The shared audience and allowAnyAudience and the list of client IDs are removed: the schema lets them through, and the chart fails with a hint to the upgrade notes, also with the setting off, as tesk-api 2.1.0 doesn't start with the variables they stood for. The chart refuses what tesk-api 2.1.0 refuses at startup (blank or duplicate client IDs after trimming, clients without audiences, blank audiences, both fields) and fails with the setting on and tesk-api before 2.1.0, which replaces the warning of the notes for tesk-api before 2.0.0. Closes #336 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Upgrade notes with the conversion from the form of chart 0.4.0, the deployment guide's "Tokens of services" and the configuration reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
`helm upgrade --reuse-values` renders with the old release's defaults, so the defaults of chart 0.4.0 (an empty audience, allowAnyAudience false, an empty list of clients) no longer fail; only values that mean something do. Also test the default appVersion against the version gate, document how Helm changes unquoted numeric client IDs, give the upgrade order, and fix review nits in comments and docs. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Give the removed shared allowAnyAudience its old enum again, so that values that were never valid don't pass unnoticed, say in the schema and docs that the defaults of chart 0.4.0 pass, and simplify the tests of the default appVersion and the empty list. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Reviewer's GuideConfigurationUpdate token-client configuration to use per-client audiences, validate legacy values and API-version compatibility, and render the normalized client map expected by tesk-api 2.1.0.
DocumentationDocument the per-client configuration, its security implications, and the upgrade, rollout, and rollback steps.
TestsReplace the shared-audience tests with coverage for rendering, normalization, validation, legacy-value migration, and API-version gating.
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 #338 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 422 422
=========================================
Hits 422 422 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit ee20d8f #336 tokenClients: audiences per client · 2 of 6 met
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="charts/tesk/templates/_helpers.tpl" line_range="902" />
<code_context>
-{{- range (default list $tokenClients.clients) -}}
-{{- with trim (toString .) -}}
-{{- $clients = append $clients . -}}
+{{- if include "tesk.apiBefore" (dict "root" . "version" "2.1.0") -}}
+{{- fail (printf "auth.tokenClients needs tesk-api 2.1.0 or later, not %s (tesk.image.tag): tesk-api 2.0.0 reads the clients in another form and doesn't start without it, and earlier versions ignore the setting. Upgrade tesk-api, or turn auth.tokenClients off; see %s" (include "tesk.apiImageTag" .) $upgrading) -}}
{{- end -}}
</code_context>
<issue_to_address>
**Digest pins bypass API version gate**
When `auth.tokenClients.enabled` is true and `tesk.image.tag` names a 2.1.0-or-later version but its digest identifies an older tesk-api image, `tesk.apiBefore` compares the version text before `@` and ignores the digest, while the deployment pulls the image identified by that digest. A tag such as `2.1.0@sha256:<digest-of-2.0.0>` therefore passes this check but runs an incompatible API, so token clients can prevent startup or be ignored.
Treat digest-pinned images as unverifiable by this version gate, or otherwise require a trusted version indication that cannot disagree with the pinned image.
</issue_to_address>
### Comment 2
<location path="charts/tesk/templates/_helpers.tpl" line_range="881-897" />
<code_context>
+renders with the old release's defaults, and the chart never renders the
+variables of tesk-api 2.0.0 */ -}}
+{{- $removed := list -}}
+{{- if include "tesk.isSet" $tokenClients.audience -}}
+{{- $removed = append $removed "auth.tokenClients.audience" -}}
+{{- end -}}
+{{- if eq (toString $tokenClients.allowAnyAudience) "true" -}}
+{{- $removed = append $removed "auth.tokenClients.allowAnyAudience" -}}
</code_context>
<issue_to_address>
**Schema permits legacy values**
The issue asks for the old list form and shared `audience` to fail schema validation with a hint. This change instead allows those forms through the schema and rejects meaningful values later in the template; the schema also permits client settings with missing or empty audiences.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if the client-to-audience mapping is wrong, tokens may be accepted for a client they were not meant to authorize, allowing that client to create tasks on the cluster. Reverting restores the previous checks, but cannot undo tasks or other actions taken while the incorrect authorization was active.
Blocking findings: charts/tesk/templates/_helpers.tpl:902
Say what allowAnyAudience does, that any token issued to the client is accepted (also one leaked from or replayed by another service), that it is meant for testing and setting up federations, and that production should list audiences (decision d21). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Summary
Chart side of audiences per service client, matching elixir-cloud-aai/tesk-api#220 (tesk-api#215). Merge together with tesk-api#220, so that the
devheads stay compatible.auth.tokenClients.clientsis a map from client ID to the client's settings:audiences(a non-empty list) orallowAnyAudience: true, not both (proposal of the issue: per client, defaultfalse). The chart renders one JSON variable,TESK_API_AUTHORISATION_SERVICE_CLIENTS_CLIENTS, normalised to what tesk-api 2.1.0 accepts:{"audiences": [...]}or{"allowAnyAudience": true}per client, with IDs and audiences trimmed,allowAnyAudienceas a JSON boolean (also from"true"), a non-trueallowAnyAudienceleft out, and null clients left out (null removes a key in Helm).…_CLIENT_IDSand…_AUDIENCEare never rendered. The sharedauth.tokenClients.audienceandallowAnyAudienceandclientsas a list are removed. The schema lets them through, and the chart fails with a hint to the upgrade notes when they hold values that mean something (a non-emptyaudience,allowAnyAudience: true, or a non-empty list), also when the setting is off. The defaults of chart 0.4.0 pass, becausehelm upgrade --reuse-valuesrenders with the old release's defaults. This follows the chart's existing pattern for removed keys ($defs/removed,tesk.checkRemovedValues). The issue asked for a schema failure with a hint, but Helm's schema errors can't carry one.allowAnyAudience: true), a blank audience, or both fields. The schema checks the structure: per-clientadditionalProperties: false, non-blank IDs and audiences, and booleans.tesk.image.tagas a version, by defaultappVersion, still 2.0.0 ondev), the chart fails instead of starting a tesk-api that doesn't start (2.0.0) or ignores the setting (earlier). This replaces the notes' warning for tesk-api before 2.0.0. Tags that aren't versions (e.g.dev) aren't checked.allowAnyAudiencestays opt-in for testing (decision d21 of the maintainer, 2026-11-23): kept for testing and for setting up federations while the audiences at an IdP that one doesn't control are being sorted out. Thevalues.yamlcomments, the schema description, the configuration reference, the deployment guide ("Tokens of services") and the upgrade notes say what it does (accepts that client's tokens whatever theiraud), the risk (every token that the trusted issuer issues to that client ID is accepted, also tokens meant for other services, so a token leaked from or replayed by another service works here), and that production should list audiences; tesk-api#220 logs a warning at startup for each such client.values.yamlcomments are updated too.Closes #336
Verification
pytest(all tests, Helm v3.22.1 as in CI,REQUIRE_HELM=1): 1274 passed. The token client tests are rewritten for the map form: rendering and normalisation, JSON escaping, values files with numeric IDs, every template refusal, schema refusals, the removed forms with their hint (also when off), the 0.4.0 defaults passing, the link target in the upgrade notes, and the version gate, both with explicit tags and with the defaultappVersion.helm lint charts/tesk --strict: OK.mkdocs build --strict: OK.pre-commit run --all-files: all hooks pass.actionlintwas skipped locally because of a missing local shellcheck; no workflow is changed.chart-install) uses the default values (tesk-apiappVersion2.0.0,auth.mode: noauth, token clients off), so it doesn't touch this setting and stays green. tesk-api pushes images only fromdev, so no image with fix: default to taskmaster and filer v0.10.6 #220 exists until it merges, and a local build of fix: default to taskmaster and filer v0.10.6 #220 was blocked by the sandbox's proxy. The rendered JSON is checked against fix: default to taskmaster and filer v0.10.6 #220's parser rules (ServiceClientTokenServices.clients) in the unit tests. Proposed follow-up: onceappVersionis 2.1.0, add a kind case withauth.tokenClientson that checks tesk-api starts.CI passedgreen, also both kind installs (they don't exercise token clients, see above).pytest tests/test_chart.py(Helm v3.22.1): 1033 passed;mkdocs build --strict: OK;pre-commit run --all-files: all hooks pass; CI on ee20d8f: all 25 checks pass.Reviews: two rounds of
adversarial-reviewerandquality-reviewer. Fixed:--reuse-valuesupgrades from 0.4.0 failed on that chart's defaults (medium).appVersionwas missing (medium).enumis back on the removedallowAnyAudience(low).Declined review findings
String.strip(adversarial, low). Go and Java differ only in rare characters (e.g. NBSP, U+001C). Either way such a value is refused, by the chart or at tesk-api's startup, never accepted wrongly. This is noted in the template comment.Open questions
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
Summary by Sourcery
Adopt per-client token audiences in the chart and enforce compatibility with tesk-api 2.1.0 and later.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: