Repository navigation
Conversation
The website is gaining API keys (website#142), and limits are per account, so a keyed call will name its caller to the backends as `x-dfo-caller: user:<32 lowercase hex digits>` (an HMAC digest of the account id, the same shape as the `ip:` form) in place of `ip:<digest>`. `resolve_caller` now accepts either form beside a vouched `x-dfo-caller-principal`: `ip:` stays `kind="address"` and `user:` is the new `kind="account"`. A `user:` caller is accepted only with the principal, so a direct request cannot claim an account, and the X-Forwarded-For path is unchanged. Shares, presentation cards and pins therefore count per account. Anything else still refuses 400 `request_invalid`, and the message names both forms. `datasets-maintenance settle` told caller keys from raw secrets by the `ip:` prefix, so it would have rewritten a `user:` pin principal to a `secret-sha256:` label. Its pattern now admits `user:` keys as well. This ships ahead of dfo-ai and the website sending `user:` callers. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015QQk2mKJZzXv2AYykDjvQf
This was referenced Nov 16, 2026
The quickstart said the API accepts requests without a key. Anonymous calls still work, but a key now raises the per-caller limit. Say so, name the two headers, and link the API keys page. Refs DevelopmentFinanceObservatory/website#142 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of DevelopmentFinanceObservatory/website#142, API keys on the website's platform proxy. Limits are per account, so the website names a call made with an API key to the backends as
x-dfo-caller: user:<32 hex>. The hex is an HMAC digest of the account id, the same shape as today'sip:form.resolve_calleracceptsuser:<32 lowercase hex>beside a vouchedx-dfo-caller-principal, as a new caller kind,account.ip:callers are unchanged.user:header without the principal is ignored, and the X-Forwarded-For path names the caller.datasets_api/maintenance.py: the deploy-time settle treated any principal that was notsecret-sha256:orip:as a raw pin secret and rewrote it to a hash label. Auser:pin principal would have been rewritten, which breaks the account's repeat-pin match._LABELLEDnow accepts(ip|user):. Migration 0026 is unchanged; it is immutable.Caller.kind. The allowance ledger, pins, shares, cards and exports key oncaller.keyalone, so they count per account as they stand.datasets_api/README.mdand the deploy workflow comment now name both forms.Test plan
just lintandjust typecheck.tests/platform/test_caller.py:user:is accepted when vouched, with kindaccount, and is the same caller from any address.user:without the principal falls back to the address.tests/datasets_api/test_allowance.py: an account's count is kept apart from addresses, and refunds work.tests/datasets_api/test_pin_door.py: a voucheduser:pin is keyed and spent per account, and a malformed one answers 400.tests/datasets_api/test_maintenance.py: the settle statements use the(ip|user)pattern.tests/dataset_store/test_live.py: the live settle seeds auser:key and checks it survives two runs. This needs live Postgres, so it runs in CI only.test_store_budgettests fail identically on a cleandev.Coordination
Ship this first. dfo-ai then forwards
user:callers (dfo-aifeat/keyed-caller), and the website starts sending them last (website #143).Docs:
docs/guide/quickstart.mdnow says an API key is optional, linking the hub's new "Use an API key" page. Merge DevelopmentFinanceObservatory/docs#26 first, or the docs build's link check reports that link as broken.🤖 Generated with Claude Code
https://claude.ai/code/session_015QQk2mKJZzXv2AYykDjvQf