Repository navigation
feat: allow only https service URLs by default - #152
Conversation
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]>
Reviewer's GuideService 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 validationsequenceDiagram
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
Sequence diagram for startup warnings on stored service URLssequenceDiagram
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
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 #152 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 9
Lines 743 770 +27
=========================================
+ Hits 743 770 +27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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="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
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]>
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
httpby default.custom.endpoints.services.url_schemes(list ofhttp/https, non-empty), default[https]in the model and inconfig.yaml.POST/PUTof a service whoseurluses another scheme returns400problem details:Service URLs must use an allowed scheme: 'https'.The check is case-insensitive and ignores the surrounding spaces that service URLs tolerate.documentationUrlandorganization.urlstay HTTP(S), andcontactUrlalso acceptsmailto:. The issue is about service URLs only, since tokens are sent there.config.dev.yaml) allows[http, https], so local use keeps working.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: passmkdocs build --strict: pass[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 inconfig.yaml. Kept on purpose, as in other options:config.yamldocuments the values, and the model default covers configs without the key.Sourcery: hide stored
httpservices, 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
idbut with a disallowed scheme would raiseKeyErrorat startup. Declined: services always have anid(unique index, API), andadd_service_keys()makes the same assumption.Open questions
None.
🤖 Generated with Claude Code