Skip to content

feat: allow only https service URLs by default - #152

Merged
uniqueg merged 4 commits into
devfrom
feat/https-service-urls
Oct 21, 2026
Merged

uniqueg merged 4 commits into
devfrom
feat/https-service-urls

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Clients (Krini, the ELIXIR On-Cloud components, proTES) send access tokens to the services they find in the registry, so service URLs should not be plain http by default.

  • New app option custom.endpoints.services.url_schemes (list of http/https, non-empty), default [https] in the model and in config.yaml.
  • POST/PUT of a service whose url uses another scheme returns 400 problem details: Service URLs must use an allowed scheme: 'https'. The check is case-insensitive and ignores the surrounding spaces that service URLs tolerate.
  • Links are unchanged: documentationUrl and organization.url stay HTTP(S), and contactUrl also accepts mailto:. The issue is about service URLs only, since tokens are sent there.
  • Docker Compose (config.dev.yaml) allows [http, https], so local use keeps working.
  • Stored services: on startup, the app warns about stored services whose URLs use a scheme that is not allowed, naming them. They are still served, but can only be updated with an allowed scheme. Fresh 0.3.0 installs start with an empty database, so the app does not refuse to start over them.
  • Docs: a new "Service URL schemes" section on the configuration page, plus updates to the API, upgrading and local-overrides pages, the chart README, the API spec descriptions and the 0.3.0 release notes (API and configuration).

Closes #147

Verification

  • coverage run --source=cloud_registry -m pytest -p no:warnings (with Helm 3.18.6): 752 passed; coverage report: 100%
  • ruff check ., ruff format --check ., mypy (strict settings), ast-grep scan: pass
  • mkdocs build --strict: pass
  • CI: all checks pass (tests on 3.10 and 3.12, static analysis, Helm, docs, Docker Compose smoke test, codecov patch and project, Read the Docs).
  • New tests: http rejected by default for POST and PUT, at the unit and app level; http accepted when allowed; only listed schemes accepted ([http]); config model validation; base and dev config values; startup warning with and without such services.

Declined review findings

  • quality-reviewer (low): the default [https] is set both in the model and in config.yaml. Kept on purpose, as in other options: config.yaml documents the values, and the model default covers configs without the key.

  • Sourcery: hide stored http services, or refuse to start while they exist. Declined, with the reasons in the thread: the issue allows documenting, 0.3.0 installs start with an empty database, and the warning names the affected services. The other Sourcery finding (malformed stored URLs reported) is fixed.

  • adversarial-reviewer (low): a stored document without id but with a disallowed scheme would raise KeyError at startup. Declined: services always have an id (unique index, API), and add_service_keys() makes the same assumption.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 3 commits October 21, 2026 22:25
Clients send access tokens to the registered services, so service URLs
must use a scheme of the new option custom.endpoints.services.url_schemes
(default: https only); others are rejected with 400 and the allowed
schemes in the problem details. The Docker Compose overlay allows http
too. Links keep HTTP(S), contact URLs mailto:.

On startup, the app warns of stored services whose URLs use schemes that
are not allowed; they are still served.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe custom.endpoints.services.url_schemes on the configuration,
API and upgrading pages and in the chart README, note that Docker
Compose allows http, and list the change in the 0.3.0 release notes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Say in the API specification that service URLs must be https URLs
unless the deployment allows http, re-wrap the registrations paragraph,
explain why the startup warning skips invalid stored URLs, and tighten
the tests of the warning (allowed http, named service).

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

sourcery-ai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Service registrations now enforce configurable HTTP/HTTPS schemes, defaulting to HTTPS to protect access tokens, while Docker Compose remains HTTP-compatible for local development. Existing incompatible services remain available with startup warnings and restricted updates, and the API, configuration, deployment, upgrade, and release documentation has been updated accordingly.

Sequence diagram for configurable service URL validation

sequenceDiagram
    participant Client
    participant API
    participant ServiceRegistry
    participant Config

    Client->>API: POST /services or PUT /services/{serviceId}
    API->>ServiceRegistry: register_metadata()
    ServiceRegistry->>Config: Read url_schemes
    ServiceRegistry->>ServiceRegistry: check_url_scheme(url, schemes)
    alt Allowed scheme
        ServiceRegistry-->>API: Store service
        API-->>Client: 201 Created
    else Disallowed scheme
        ServiceRegistry-->>API: InvalidService
        API-->>Client: 400 Problem Details
    end
Loading

Sequence diagram for startup warnings on stored service URLs

sequenceDiagram
    participant App
    participant ServiceRegistry
    participant Config
    participant Database
    participant Logger

    App->>ServiceRegistry: warn_url_schemes()
    ServiceRegistry->>Config: Read url_schemes
    ServiceRegistry->>Database: Find stored service ids and urls
    loop Each stored service URL
        ServiceRegistry->>ServiceRegistry: check_url_scheme(url, schemes)
    end
    ServiceRegistry->>Logger: warning for incompatible service ids
    App-->>App: Continue serving stored services
Loading

File-Level Changes

Change Details Files
Adds configurable scheme enforcement for registered service URLs, defaulting to HTTPS while preserving separate link URL rules.
  • Adds validated url_schemes configuration with [https] as the default and [http, https] for Docker Compose development.
  • Checks service URL schemes during registration and replacement, with case-insensitive matching, tolerated surrounding spaces, and actionable 400 errors.
  • Keeps documentation, organization, and contact URL validation independent of service URL scheme restrictions.
cloud_registry/ga4gh/registry/service.py
cloud_registry/service_models/custom_config.py
cloud_registry/config.yaml
config.dev.yaml
tests/ga4gh/registry/test_service.py
tests/service_models/test_custom_config.py
tests/test_app.py
tests/test_config.py
Adds startup compatibility handling for services stored before the HTTPS-only default.
  • Scans stored service URLs at application startup and logs the IDs of services using disallowed schemes.
  • Continues serving affected services while requiring allowed schemes for subsequent updates.
  • Documents upgrade, deployment, and operational behavior for existing HTTP services.
cloud_registry/app.py
cloud_registry/ga4gh/registry/service.py
docs/configuration.md
docs/upgrading.md
deployment/README.md
docs/releases/0.3.0.md
tests/ga4gh/registry/test_service.py
tests/test_app.py
Updates API specifications and user-facing documentation to describe the new service URL policy and configuration.
  • Clarifies that HTTPS is required by default and HTTP is deployment-configurable in the OpenAPI schema and API guide.
  • Adds configuration guidance, local development behavior, chart documentation, and release notes.
cloud_registry/api/additions.openapi.yaml
docs/api.md
docs/configuration.md
deployment/README.md
docs/releases/0.3.0.md
docs/upgrading.md
docker-compose.yaml

Assessment against linked issues

Issue Objective Addressed Explanation
#147 Add a configurable allowlist for service URL schemes, defaulting to HTTPS only, and reject service registrations or updates using disallowed schemes with problem details while leaving link URL rules unchanged. ✅
#147 Keep the Docker Compose development setup working with HTTP service URLs, and handle existing stored services that use disallowed schemes without preventing startup. ✅
#147 Document the setting and its behavior in the configuration and chart documentation, and include it in the 0.3.0 release notes. ✅

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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (af0c7f9) to head (83bee83).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #152   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          743       770   +27     
=========================================
+ Hits           743       770   +27     

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

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

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

## Individual Comments

### Comment 1
<location path="cloud_registry/ga4gh/registry/service.py" line_range="770-800" />
<code_context>
+def warn_url_schemes() -> None:
</code_context>
<issue_to_address>
**Legacy HTTP services still receive tokens**

When a deployment has a stored `http` service URL and switches to the default `[https]` configuration, `warn_url_schemes()` only logs the stored service IDs; the service remains available through the public listing and lookup endpoints, so clients can continue sending access tokens to its `http` URL in cleartext.

Prevent disallowed stored services from being returned or followed unless `http` is explicitly re-enabled, or require operators to migrate them before serving them.
</issue_to_address>

### Comment 2
<location path="cloud_registry/ga4gh/registry/service.py" line_range="789-790" />
<code_context>
+            continue
+        try:
+            check_url_scheme(url, schemes=schemes)
+        except InvalidService:
+            ids.append(f"'{service['id']}'")
+        except ValueError:
+            # invalid URLs stored before URLs were checked can't be updated
</code_context>
<issue_to_address>
**Malformed URLs trigger scheme warnings**

When a stored service has a URL that `urlsplit()` parses but `normalize_url()` rejects, such as `http://`, and its parsed scheme is not allowed, `check_url_scheme()` checks only the parsed scheme, so a stored URL such as `http://` raises `InvalidService` and is reported as a disallowed-scheme service even though it has no host. Operators see a misleading startup warning for a URL that should be skipped as invalid.

Validate stored URLs with the same URL checks used by `normalize_url()` before checking their schemes, skipping invalid URLs.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and if HTTP is accepted unintentionally, a registered service URL can cause clients to send access tokens in cleartext; reverting cannot recover tokens already exposed. The default is HTTPS-only, while existing HTTP registrations are warned about but remain served.

Blocking findings: cloud_registry/ga4gh/registry/service.py:800, cloud_registry/ga4gh/registry/service.py:790


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

Stored URLs that urlsplit() accepts but normalize_url() rejects, such
as http:// without a host, were reported as using a scheme that is not
allowed; skip all invalid URLs instead (review finding of Sourcery).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg merged commit b985128 into dev Oct 21, 2026
12 checks passed
@uniqueg
uniqueg deleted the feat/https-service-urls branch October 21, 2026 21:10
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: allow only https service URLs by default

1 participant