Repository navigation
feat(config)!: drop identity provider defaults - #183
Conversation
Turn the chart into a thin chart over foca-common 0.1.0 (OCI, pinned in Chart.yaml, locked in Chart.lock): the templates include the library's resources with the app's settings (values key cloudRegistry, body size limit, audience required, databases, access control database and the public URL from hostName). The app keeps its own checks (renamed and removed keys, legacy releases, admin mapping); the library adds an external MongoDB (mongodb.enabled), image pull policies and the checks of an external MongoDB's host and the MongoDB image. The rendered resources are unchanged for the documented values, except for a comment of the init script. Values keep their keys and defaults. CI and the release build the dependency; the release checks that the package contains the locked library version. The chart README's links to FOCA point to the library's tag, checked by a test. Closes #158 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Run the app's checks in every template, before the library's, so that renamed and removed values are reported first (e.g., host_name without hostName). Pin the digest of the library archive and check it in CI and on release, as OCI tags can be pushed again. Warn that disabling the bundled MongoDB of an installed release deletes its volume. Test the values schema against the library's, an external MongoDB without authentication and a clear error without built dependencies; tidy the docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Run the legacy release check, which looks up resources in the cluster, once (in the ConfigMap template) instead of in every template, and report the missing admin mapping instead of a template error for config.security: null. Parametrize the renamed keys test and fix the wording of the release notes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The identity provider is deployment configuration: the base config trusts no token issuers, reads no claims from the user info and sets no group claim. FOCA refuses access control without issuers, and the app now refuses group mappings without a group claim; the chart fails to render in both cases. The development config trusts a fictitious issuer. Name the path parameter of the roles of groups `group`. BREAKING CHANGE: deployments must set security.auth.issuers and, with group mappings, security.access_control.claim_groups (and security.auth.userinfo_claims if the identity provider releases the claims via user info only). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe in one place (Deployment configuration) which identity provider settings each deployment sets, without defaults, and how to change the policies via an overlay. Make the access control docs, the chart docs, the API spec and the 0.3.0 notes generic, and add upgrade notes for versions before 0.3.0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # deployment/README.md # deployment/templates/_helpers.tpl
The merge of dev kept both versions of test_security_config_empty; keep the one that expects the required issuers first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reject group claims that aren't strings in the chart, and warn on startup without a group claim, as users then have no groups and roles of groups don't apply. The development config sets an example group claim. Scan only text files for identity provider specific values, with word boundaries. Link to "Deployment configuration" instead of repeating it, and reflow the edited docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Treat a blank group claim as unset in the app, as the chart does. Scan all text files for identity provider specific values, also in names with underscores. Mention the example group claim of the development config, and name the required settings in the 0.3.0 notes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis breaking change removes all identity-provider defaults, requires deployments to provide trusted issuers and applicable group claims, and enforces those requirements both during application startup and Helm rendering. The PR also replaces provider-specific documentation and fixtures with generic or fictitious values, renames group-permission API parameters without changing URLs, and adds comprehensive validation, upgrade guidance, and repository-genericity tests. Sequence diagram for deployment-specific token and group validationsequenceDiagram
participant Deployment
participant Helm as Helm chart
participant App as create_app
participant FOCA
Deployment->>Helm: Render config overlay
Helm->>Helm: Validate issuers
Helm->>Helm: Validate claim_groups and group_mapping
Helm-->>Deployment: Rendered manifests or failure
Deployment->>App: Start registry
App->>FOCA: Validate security config
FOCA-->>App: Validate issuers and audience
App->>App: check_admin_groups()
App-->>Deployment: Start, warning, or RuntimeError
Sequence diagram for group permission API parameter renamesequenceDiagram
actor Client
participant API
participant Permissions
Client->>API: PUT /services/{serviceId}/permissions/groups/{group}
API->>Permissions: putServiceGroupPermission(serviceId, group)
Permissions->>Permissions: get_current_group_values()
Permissions->>Permissions: _put_role(serviceId, group, group)
Permissions-->>API: group and role
API-->>Client: Permission result
Flow diagram for identity provider configuration validationflowchart TD
Overlay[Deployment overlay or Helm config] --> AppConfig[Base config with no identity provider defaults]
AppConfig --> Issuers{Non-blank issuers configured?}
Issuers -->|No| StartupFail[Startup or Helm rendering fails]
Issuers -->|Yes| GroupClaim{Group claim configured?}
GroupClaim -->|No mapping| Warning[App starts with no user groups warning]
GroupClaim -->|Mapping without claim| MappingFail[Startup or Helm rendering fails]
GroupClaim -->|Claim configured| AdminMapping{Admin mapping valid?}
AdminMapping -->|Required mapping missing| StartupFail
AdminMapping -->|Valid or admins optional| Ready[Application starts]
File-Level Changes
Assessment against linked issues
Possibly linked issues
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 #183 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 12 12
Lines 813 820 +7
=========================================
+ Hits 813 820 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docs/configuration.md" line_range="24-26" />
<code_context>
+defaults for them, so each deployment sets them in an overlay (or in the
+chart's `config` value), otherwise the app refuses to start:
+
+- `security.auth.issuers`: the trusted token issuers (the `iss` claim of their
+ tokens, e.g., `https://login.example.org/oidc/`); tokens of other issuers
+ are rejected (see [Authentication](access-control.md#authentication));
+- `security.auth.audience`: the client IDs of the apps whose tokens are
+ accepted (the `aud` claim, e.g., of the registry's front end), unless
</code_context>
<issue_to_address>
**Trusted issuers share stored subjects**
When a deployment trusts multiple issuers and two users from different issuers have the same `sub`, `get_current_subject()` supplies only `sub`, and `_put_role()` stores user roles under that subject without the token issuer. Users from different trusted issuers with the same `sub` therefore share permissions, so one issuer’s user can gain another’s service access.
Restrict the configuration to one issuer or include the issuer in persisted user-role identities and migrate existing role records.
</issue_to_address>
### Comment 2
<location path="cloud_registry/ga4gh/registry/permissions.py" line_range="75" />
<code_context>
"""
conf = get_config().security.access_control
mapping = conf.group_mapping or {}
+ claim_groups = (conf.claim_groups or "").strip()
+ if mapping and not claim_groups:
+ raise RuntimeError(
</code_context>
<issue_to_address>
**Group permissions ignore padded claims**
When `security.access_control.claim_groups` has leading or trailing whitespace, `check_admin_groups()` and the Helm helper trim the value only for validation, while FOCA receives the untrimmed configured claim name. FOCA therefore misses group memberships, so mapped admins and group roles do not apply.
Trim `claim_groups` in the value passed to FOCA, not only in the validation checks.
Also at `deployment/templates/_helpers.tpl:92`, `deployment/templates/_helpers.tpl:115`.
</issue_to_address>
### Comment 3
<location path="deployment/templates/_helpers.tpl" line_range="115" />
<code_context>
+{{- fail $issuersError -}}
+{{- end -}}
+{{- range $issuer := $issuers -}}
+{{- if not (and (kindIs "string" $issuer) (trim $issuer)) -}}
+{{- fail $issuersError -}}
+{{- end -}}
</code_context>
<issue_to_address>
**Padded issuers reject valid tokens**
When an issuer value has leading or trailing whitespace, the Helm helper uses trimming only to check that the issuer is non-empty and leaves the configured value unchanged. FOCA compares tokens’ `iss` claims against that padded value, so tokens from the intended provider fail authentication.
Trim issuer values before rendering them into the configuration passed to FOCA.
</issue_to_address>
### Comment 4
<location path="deployment/templates/_helpers.tpl" line_range="89-90" />
<code_context>
+{{- end -}}
+{{- if hasKey $securityAccessControl "claim_groups" -}}
+{{- $rawClaimGroups := get $securityAccessControl "claim_groups" -}}
+{{- if not (or (kindIs "invalid" $rawClaimGroups) (kindIs "string" $rawClaimGroups)) -}}
+{{- fail "config.security.access_control.claim_groups must be the name of a claim (a string)" -}}
+{{- end -}}
+{{- $claimGroups = $rawClaimGroups | default "" | trim -}}
</code_context>
<issue_to_address>
**Validation errors appear out of order**
When issuers are missing or invalid and `claim_groups` is not a string, the Helm helper checks the `claim_groups` type before checking issuers, so it reports the group-claim error first. Fixing that then reveals the issuer error, contrary to the stated validation order and requiring extra render-and-fix cycles.
Validate issuers before checking the `claim_groups` type.
</issue_to_address>
### Comment 5
<location path="tests/test_config.py" line_range="421-426" />
<code_context>
+ )
+ assert "config.security.auth.issuers must" in exc.value.stderr
+
+ def test_issuers(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ """The issuers and the group claim are passed to the app."""
+ overlay = _render_overlay("--set", "hostName=example.org")
+ config = _load_config(tmp_path, monkeypatch, overlay)
+ assert config.security.auth.issuers == [ISSUER]
+ assert config.security.access_control.claim_groups == GROUP_CLAIM
+
+ @pytest.mark.parametrize(
</code_context>
<issue_to_address>
**Chart output regressions go unnoticed**
When the chart stops emitting `security.auth.issuers` or `security.access_control.claim_groups`, `test_issuers` still passes because `_load_config` supplies the expected issuer and group claim from the test overlay, even when the rendered chart overlay omits them. The assertions therefore do not verify that the chart passes either value to the app.
Parse the rendered chart overlay without the test fixture, or use expected values that differ from the fixture.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 5 findings to address first, and deployments that relied on the default issuer or group claim will fail to start or render until their identity-provider settings are supplied; a bad issuer or group mapping can also change who is authenticated or receives roles. Reverting restores the defaults for future runs, but it cannot undo any outage that already occurred.
Blocking findings: docs/configuration.md:26, cloud_registry/ga4gh/registry/permissions.py:75, deployment/templates/_helpers.tpl:115, deployment/templates/_helpers.tpl:90, tests/test_config.py:426
FOCA compares issuers and looks up the group claim as written, so the chart and the app reject values with surrounding whitespace instead of trimming them for the checks only. Check the issuers first, as the app does; test the rendered overlay itself; and say that roles of users and groups are not scoped by issuer, so deployments usually trust one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The identity provider is now deployment configuration. The repository has no defaults, examples or docs for a specific identity provider; examples use fictitious values (
login.example.org,groups,registry-admins).Base config (
cloud_registry/config.yaml):issuers: []).userinfo_claimsremoved) and sets no group claim (claim_groupsremoved).Startup checks:
Helm chart (
cloud-registry.validate): rendering fails, as the app would refuse to start, in these cases:The checks run in the same order as in the app: issuers, group claim, admin mapping.
Development config (
config.dev.yaml): it trusts a fictitious issuer and sets an example group claim. FOCA only fetches the issuer's keys when it validates a token, so Docker Compose still starts.API: the path parameter of the roles of groups is now
{group}instead of{entitlement}. The URLs don't change.Docs:
docs/configuration.mdis the one place that lists the required settings: issuers, audience, group claim and user info claims, admin mapping. It also says that roles on services are granted via the API, not configured, and how to change the policies with an overlay.docs/access-control.md(rewritten),README.md,docs/index.md,docs/api.md, the chart README andvalues.yaml, the API spec and the 0.3.0 release notes.docs/upgrading.mdhas a section on upgrading from versions before 0.3.0: a fresh install with an empty database, and the identity provider settings.Guard test:
test_repository_genericchecks that no tracked text file contains identity-provider-specific values.Fix of dev's chart (in the merge commit): with
config.security.access_controlset but nogroup_mapping, the check from build(chart): use the FOCA library chart #176 that the mapping is a map failed, because sprig'sgetreturns""for missing keys. The tests cover it now (test_admins_not_required).BREAKING CHANGE: deployments must set
security.auth.issuersand, with group mappings,security.access_control.claim_groups. If the identity provider releases the group claim via user info only, they must also add it tosecurity.auth.userinfo_claims.Closes #166
Verification
pytestwith coverage (Python 3.13, Helm v3.22.1, mongomock): 975 passed, 100% coverage.create_app()refuses a group mapping without a group claim (also a blank one) and warns without a group claim;test_repository_generic;pre-commit run --all-files(ruff, mypy, semgrep, gitleaks, actionlint, ast-grep) and the gitleaks-all hook: passed.mkdocs build --strict: passed.dev.test_issuerschecks the rendered overlay itself.Declined review findings
devholds only this issue's changes.devcommits.test_issuers_requiredandtest_security_config_empty(quality, low). One tests the overlay and the other the security section as a whole, so they cover different paths.helm template, and the app test covers a blank claim.Open questions
None.
Notes for deployers
The values file of each deployment must now set
config.security.auth.issuersandconfig.security.access_control.claim_groups, plusconfig.security.auth.userinfo_claimsif the group claim comes from the user info. Before, the base config set these for one identity provider.🤖 Generated with Claude Code
Summary by Sourcery
Remove identity-provider defaults and require deployments to configure authentication and group-based access-control settings explicitly.
New Features:
Bug Fixes:
Enhancements:
entitlementtogroupwithout changing the URLs.CI:
Deployment:
Documentation:
Tests: