Repository navigation
build: require FOCA 0.16 and Python 3.13 - #165
Conversation
Require foca>=0.16.0,<0.17 and build on elixircloud/foca:0.16.0-py3.13 (pinned by digest). The app ships as an image, so it targets one Python version, that of the image: requires-python >=3.13, the 3.13 classifier only, ruff target py313 and mypy python_version 3.13. CI and Read the Docs use Python 3.13 throughout. The test matrix (3.10, 3.12) becomes a single job named "Run tests (mongomock)", without the Python version, so required checks don't change when it is bumped; the aggregate "Run tests" check still covers it. A test checks that the Dockerfile, pyproject.toml, the workflows and Read the Docs agree on the Python version. Also raise idna to >=3.15 (as FOCA 0.16, CVE-2026-45409), drop the tomli fallback and use datetime.UTC (ruff UP017 for py311+). Co-Authored-By: Claude Opus 5.5 <[email protected]>
FOCA 0.16 rejects bearer tokens without the RFC 9068 type (typ header at+jwt), e.g., ID tokens; LS Login issues such access tokens. Set security.auth.verify_token_type explicitly in the base config and document it. Test that access token types are accepted and other tokens rejected, that 401 responses carry a Bearer challenge (WWW-Authenticate: Bearer, with error="invalid_token" for invalid tokens), also for GET /me and FOCA's permissions API, and that 405 responses carry Allow, as FOCA 0.16 keeps the headers of HTTP errors. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rewrap the edited paragraphs (API errors, 0.3.0 notes, docs extra comment), drop the Python version from the Dockerfile comment and fix the comment of the MongoDB test job (one other test job now). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR upgrades Cloud Registry to the FOCA 0.16/Python 3.13 baseline, consolidates CI around stable Python-independent check names, enforces RFC 9068 access tokens with documented error headers, and adds tests and migration documentation to keep runtime configuration consistent. Sequence diagram for access-token validation and error headerssequenceDiagram
actor Client
participant Registry
participant FOCA
Client->>Registry: HTTP request with Bearer token
Registry->>FOCA: Verify token
alt token is an RFC 9068 access token
FOCA-->>Registry: Token accepted
Registry-->>Client: Protected response
else token is invalid or not an access token
FOCA-->>Registry: Token rejected
Registry-->>Client: 401 Unauthorized
Registry-->>Client: WWW-Authenticate: Bearer error="invalid_token"
end
Flow diagram for stable test checksflowchart LR
Mongomock["Run tests (mongomock)\nPython 3.13"] --> Aggregate["Run tests"]
MongoDB["Run tests (MongoDB 7.0)\nPython 3.13"] --> Aggregate
Aggregate --> Required["Stable required check"]
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 #165 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 11 11
Lines 880 880
=========================================
Hits 880 880 ☔ 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/config.yaml" line_range="37" />
<code_context>
+ # Only access tokens as per RFC 9068 (`typ` header `at+jwt`, as issued
+ # by LS Login); other tokens of the issuers, such as ID tokens, are
+ # rejected
+ verify_token_type: True
# Trusted token issuers (`iss` claim); tokens of other issuers are
# rejected
</code_context>
<issue_to_address>
**Valid provider tokens rejected**
When LS Login issues an otherwise valid access token whose `typ` header is not accepted by FOCA 0.16, fOCA rejects every authenticated request whose token header does not use the configured RFC 9068 type, and callers receive `401 Unauthorized`. The token tests create synthetic JWTs with `make_headers`; they do not verify the format of tokens actually issued by LS Login.
Verify a real LS Login access token against FOCA 0.16 before release, and align the configured validation with the issuer's actual token format.
</issue_to_address>
### Comment 2
<location path="tests/conftest.py" line_range="208" />
<code_context>
Returns:
Request headers.
"""
+ jwt_headers = {"kid": "rsa1"} if typ is None else {"kid": "rsa1", "typ": typ}
now = int(time.time())
token = jwt.encode(
</code_context>
<issue_to_address>
**Missing-type tokens escape test**
When `test_other_token_types` exercises `typ=None`, `make_headers` omits `typ`, but `jwt.encode` adds `typ: JWT`, so the test exercises the `JWT` case twice and a token with no `typ` can be accepted without failing the test.
Make `make_headers` produce a token with no `typ` header when `typ=None`.
Also at `tests/test_app.py:205`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and enabling FOCA’s token-type check means signed tokens without an RFC 9068 access-token type are rejected, while tokens incorrectly accepted as access tokens could gain authenticated access. Reverting restores the previous check, but any data or access exposed before then cannot be taken back.
Blocking findings: cloud_registry/config.yaml:37, tests/conftest.py:208
PyJWT sets `typ: JWT` when the headers lack `typ`, so make_headers(typ= None) sent a JWT-typed token and the no-type case was never tested. Pass `typ: None`, which PyJWT omits, and check the header in the test. Co-Authored-By: Claude Opus 5.5 <[email protected]>

Closes #156
Summary
foca>=0.16.0,<0.17, base imageelixircloud/foca:0.16.0-py3.13(pinned by digest);idna>=3.15(as FOCA, CVE-2026-45409).requires-python = ">=3.13", only the 3.13 classifier, ruffpy313, mypypython_version = "3.13"; all workflows and Read the Docs use 3.13. Thetomlifallback is gone, anddatetime.UTCreplacestimezone.utc(ruff UP017). A new test (test_python_version) checks that theDockerfile,pyproject.toml, the workflows and Read the Docs agree.docker-compose.yaml); the aggregate "Run tests" still needs both. No 3.14 job.typ: at+jwt(RFC 9068; LS Login issues such tokens); the base config setssecurity.auth.verify_token_type: Trueexplicitly, and the docs say so. The test token fixture already settyp;make_headers()takes the type now.WWW-Authenticate: Beareron 401 responses (also forGET /meand FOCA's permissions API),Bearer error="invalid_token"for invalid and non-access tokens, andAllowon 405 responses. The docs (API, Access control) describe them.Not in this PR: FOCA's ownership API and URL helpers (#157), the
foca-commonlibrary chart (#158). The other FOCA 0.16 breaking changes don't affect the registry: noswagger_ui_path,group_mappingmaps toadminonly (not a resource role), Gunicorn's control socket was already disabled, and 413 already had the titleContent Too Large.Required checks
The old jobs "Run tests (Python 3.10)" and "Run tests (Python 3.12)" no longer exist. "Run tests" (already required) now covers "Run tests (mongomock)" and "Run tests (MongoDB 7.0)". Optionally also require
Run tests (mongomock)andRun tests (MongoDB 7.0)directly; neither name will change with Python bumps.Verification
Local, Python 3.13.15, FOCA 0.16.0:
coverage run --source cloud_registry,scripts -m pytest(with Helm v3.22.1): 892 passed;coverage report: 100%MONGODB_TEST_URI=… pytestagainst MongoDB 7.0: 892 passedruff check .,ruff format --check .(0.17.1),mypy,ast-grep scan,semgrep --config=.semgrep,actionlint(1.7.12): cleanmkdocs build --strict: OK;uv build: wheel contents as expected,Requires-Python: >=3.13WWW-Authenticate: Bearer/Bearer error="invalid_token", error_description=…; 405Allow: OPTIONS, GET, HEADCI (run 39823030828): all jobs pass (Static code analysis, Run tests (mongomock) with 892 passed, Run tests (MongoDB 7.0), Run tests, Check Helm chart, Build documentation, Run app with Docker Compose, Read the Docs); the Codecov upload succeeded.
Declined review findings
Pre-push reviews (adversarial, quality) found no high or medium issues; the low ones about wrapping and stale comments are fixed. Declined (low):
test_python_version, or splitting it: pytest's assertion rewriting already shows the compared values, which identify the place.verify_token_type: True: it is FOCA's default, and the behaviour tests (test_other_token_types) fail if token types stop being checked.Sourcery (after marking ready): the no-
typtoken test actually senttyp: JWT(PyJWT default); fixed in 7338bb9. Its other thread (real LS Login token format) is answered: requiringat+jwtis FOCA 0.16's default and the issue's plan; see the note below.Before the release (not a code change): that LS Login sets
typ: at+jwton its access tokens is taken from the FOCA 0.16 migration guide; confirming it once with a real token before the release is worthwhile, as every authenticated request would get 401 otherwise.Open questions
None.
🤖 Generated with Claude Code