Skip to content

feat(config)!: drop identity provider defaults - #183

Merged
uniqueg merged 12 commits into
devfrom
feat/generic-auth-config
Oct 22, 2026
Merged

uniqueg merged 12 commits into
devfrom
feat/generic-auth-config

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

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):

    • It trusts no token issuers (issuers: []).
    • It reads no claims from the user info (userinfo_claims removed) and sets no group claim (claim_groups removed).
    • The comments say what deployments must set, with generic examples.
  • Startup checks:

    • FOCA 0.16 already refuses access control without issuers, and issuers without an audience, so the app needs no check for those.
    • The app now refuses group mappings without a group claim, because no mapping would apply.
    • It warns when no group claim is set, because users then have no groups.
    • A blank claim counts as unset.
  • Helm chart (cloud-registry.validate): rendering fails, as the app would refuse to start, in these cases:

    • no list of non-blank issuers;
    • a group mapping without a group claim;
    • a group claim that isn't a string.

    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:

    • A new "Deployment configuration" section in docs/configuration.md is 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.
    • These were made generic: docs/access-control.md (rewritten), README.md, docs/index.md, docs/api.md, the chart README and values.yaml, the API spec and the 0.3.0 release notes.
    • docs/upgrading.md has 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_generic checks that no tracked text file contains identity-provider-specific values.

  • Fix of dev's chart (in the merge commit): with config.security.access_control set but no group_mapping, the check from build(chart): use the FOCA library chart #176 that the mapping is a map failed, because sprig's get returns "" for missing keys. The tests cover it now (test_admins_not_required).

BREAKING CHANGE: deployments must set security.auth.issuers and, 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 to security.auth.userinfo_claims.

Closes #166

Verification

  • pytest with coverage (Python 3.13, Helm v3.22.1, mongomock): 975 passed, 100% coverage.
  • New or changed tests (written first):
    • the base config has no identity provider and is invalid on its own;
    • create_app() refuses a group mapping without a group claim (also a blank one) and warns without a group claim;
    • the chart's checks of issuers and the group claim, including invalid types;
    • test_repository_generic;
    • fixtures with a fictitious identity provider.
  • pre-commit run --all-files (ruff, mypy, semgrep, gitleaks, actionlint, ast-grep) and the gitleaks-all hook: passed.
  • mkdocs build --strict: passed.
  • Reviews: two rounds of adversarial and quality review. I fixed all findings except those listed below.
  • CI: all checks passed (tests with mongomock and MongoDB 7.0, Helm chart, Docker Compose, image scan and Trivy, static analysis, docs, CodeQL, codecov patch and project, Read the Docs), also after the fixes for Sourcery's review (3123d60) and the merge of dev.
  • Sourcery review, 5 threads:
    • 4 fixed in 3123d60: the app and the chart reject issuers and group claims with surrounding whitespace, because FOCA compares them as written; the chart checks the issuers first; test_issuers checks the rendered overlay itself.
    • 1 documented ("trusted issuers share stored subjects"): roles are stored without the issuer, as FOCA's subject model does, and FOCA warns when several issuers are trusted. "Deployment configuration" now says to usually trust one issuer. Scoping subjects by issuer would be a FOCA change.

Declined review findings

  • Rebase so that the branch has no commits of build(chart): use the FOCA library chart #176 or merge commits (quality, medium). The PR is squash-merged, and its diff against dev holds only this issue's changes.
  • The upgrading page says that earlier versions accepted tokens of any issuer (quality, low). That is how the previously deployed version (FOCA 0.12) behaved, as the 0.3.0 upgrade notes say. The LS Login default was only on unreleased dev commits.
  • Remove the overlap between test_issuers_required and test_security_config_empty (quality, low). One tests the overlay and the other the security section as a whole, so they cover different paths.
  • A test for a whitespace-only group claim without mappings (quality, low). The adversarial reviewer checked it with 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.issuers and config.security.access_control.claim_groups, plus config.security.auth.userinfo_claims if 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:

  • Make identity provider settings deployment-specific by removing provider defaults from the base configuration and replacing them with generic examples.
  • Add startup and Helm validation for trusted issuers and group-claim configuration.
  • Provide fictitious identity-provider settings for development and test environments.

Bug Fixes:

  • Prevent group mappings from being configured without a usable group claim.
  • Handle missing Helm configuration keys correctly when validating access-control settings.

Enhancements:

  • Generalize the API, documentation, and deployment guidance for arbitrary OpenID Connect providers.
  • Rename the group-permission path parameter from entitlement to group without changing the URLs.
  • Add checks ensuring tracked repository text remains free of identity-provider-specific values.

CI:

  • Update CI deployment checks to use the fictitious development issuer.

Deployment:

  • Require Helm deployments to configure trusted issuers and validate issuer, group-claim, and mapping settings before rendering.

Documentation:

  • Document required identity-provider, claim, audience, and access-control deployment settings, including upgrade guidance.

Tests:

  • Add coverage for provider-free base configuration, application startup validation, Helm validation, and repository-generic content.

uniqueg and others added 10 commits October 22, 2026 22:43
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]>
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This 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 validation

sequenceDiagram
    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
Loading

Sequence diagram for group permission API parameter rename

sequenceDiagram
    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
Loading

Flow diagram for identity provider configuration validation

flowchart 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]
Loading

File-Level Changes

Change Details Files
Removed identity-provider-specific defaults and made authentication, claims, and group-role configuration deployment-owned.
  • Cleared default issuers and identity claims from the base configuration.
  • Added generic deployment examples and documentation covering issuers, audience, user-info claims, group claims, and admin mappings.
  • Changed development, CI, and test fixtures to use fictitious issuer and group values.
  • Added a repository-wide guard against tracked identity-provider-specific text.
cloud_registry/config.yaml
config.dev.yaml
deployment/README.md
deployment/ci/test-values.yaml
deployment/values.yaml
README.md
docs/access-control.md
docs/configuration.md
docs/index.md
docs/releases/0.3.0.md
docs/upgrading.md
tests/config_overlay.yaml
tests/conftest.py
tests/test_config.py
Added startup and Helm-render validation for required issuer and group-claim configuration.
  • Added application failure for group mappings without a non-blank group claim and a warning when no group claim is configured.
  • Added chart checks for non-blank issuer lists, string-valued group claims, and mappings that lack a group claim.
  • Handled missing Helm keys correctly with hasKey and preserved validation order aligned with application startup.
  • Expanded application and chart tests for missing, blank, null, and invalid configuration values.
cloud_registry/app.py
cloud_registry/ga4gh/registry/permissions.py
deployment/templates/_helpers.tpl
tests/test_app.py
tests/test_chart.py
tests/test_config.py
Generalized group-permission API terminology from entitlement to group without changing endpoint URLs.
  • Renamed OpenAPI path parameters, schemas, controller parameters, and documentation from entitlement to group.
  • Updated examples and descriptions to refer to the deployment-configured group claim.
  • Kept permission behavior and response structures unchanged.
cloud_registry/api/additions.openapi.yaml
cloud_registry/ga4gh/registry/permissions.py
docs/access-control.md
docs/api.md
docs/releases/0.3.0.md
Updated integration and operational configuration to work with the new identity-provider-neutral defaults.
  • Updated Docker Compose and CI workflow descriptions for fictitious development credentials.
  • Adjusted mocked user-info claims, token scopes, constants, and test fixtures.
  • Updated chart rendering helpers and tests to supply required issuer and group-claim values.
.github/workflows/checks.yaml
docker-compose.yaml
tests/helm.py
tests/test_access_control.py
tests/test_app.py
Documented the breaking upgrade requirements and deployment configuration model.
  • Added explicit 0.3.0 upgrade guidance requiring fresh installation and deployment-specific identity-provider settings.
  • Clarified that service roles are granted through the API while policies remain overlay-configurable.
  • Updated authentication, group-membership caching, verification, and deployment guidance to be provider-neutral.
docs/configuration.md
docs/upgrading.md
docs/releases/0.3.0.md
deployment/README.md
docs/access-control.md

Assessment against linked issues

Issue Objective Addressed Explanation
#166 Remove identity-provider-specific defaults and examples throughout the repository; require deployments to configure trusted issuers and audience, and ensure group mappings have a configured group claim. ✅
#166 Document deployment-specific auth, claims, group-to-role mappings, and policy configuration, and provide generic upgrade guidance for pre-0.3.0 operators, including the recommended fresh install and required settings. ✅
#166 Keep tests exercising generic group values with special characters and verify that identity-provider-specific values are absent from tracked repository text. ✅

Possibly linked issues


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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (52e90db) to head (7d8d8d2).

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.
📢 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 October 22, 2026 23:13

@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 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


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

Comment thread docs/configuration.md Resolved
Comment thread deployment/templates/_helpers.tpl Resolved
Comment thread deployment/templates/_helpers.tpl Resolved
Comment thread tests/test_config.py Resolved
uniqueg and others added 2 commits October 23, 2026 01:22
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]>
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!: make auth and group config generic

1 participant