One API key per feeder + feeder-scoped ingest URLs (migrate off shared keys)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 12/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- api, authentication, backend
Research direction
Start with the auth path: NodeAuthorizationPermission and the NodeAuth link between NodeAPIKey and ManagedNode, then common/meshcore_feeder_auth.py for the MeshCore equivalent. The issue's open points need a maintainer decision first, including the per-protocol key rule and the prod query for keys linked to several feeders. Done means the acceptance criteria are met: feeder-scoped endpoints reject shared keys, old v1/v3 URLs are unchanged, and Prometheus shows usage of old and new URLs.
Written by the indexing model from the issue text.
Description
Part of #437. This ticket should land before the feeder re-key work (ID-4) and makes that work much smaller.
Problem
Today an API key can be shared between several feeders owned by the same person (NodeAuth is many-to-many between NodeAPIKey and ManagedNode). Because of that, the feeder's node number in the URL (/api/packets/{node_id}/...) is what chooses which feeder is posting, and NodeAuthorizationPermission authorises on the pair (key, node number).
From 2.8, a node's number is crc32(public_key), so it changes on upgrade. An upgraded feeder then posts under a number its key isn't linked to, gets a 403, and ingest stops silently.
MeshCore has the same sharing built in: common/meshcore_feeder_auth.py uses the X-MeshCore-Feeder-Pubkey header to tell a user's feeders apart.
Proposal: one feeder, one API key
When a key belongs to exactly one feeder, the key on its own identifies the ManagedNode. The node number the bot reports is then just information we record, not something we authorise on. If the number changes, the feeder simply reports a new one:
- if
crc32(public_key)equals the new number, updatemeshtastic_node_idautomatically, keep the old number as an alias and notify the owner; - if it doesn't match, flag it for review rather than reject it. The likely cause is a bot config copied onto another radio.
Keys can still be rotated.
Migration
- API: add feeder-scoped endpoints with no node number in the path, for example
/api/v4/feeder/ingest/,/api/v4/feeder/nodes/and/api/v4/feeder/bot-version/. Exact paths to be decided; MeshCore gets the equivalent. These endpoints require a key linked to exactly one feeder. A shared key gets a clear 4xx telling the owner to mint a per-feeder key. - Bot: post to the new URLs. Ship this in the same bot release as feeder identity reporting (ID-5).
- Owners upgrade their bot over time. The old v1/v3 URLs keep working unchanged, shared keys included. No new shared links can be created (UI/admin), though existing ones keep working on the old URLs.
- Track usage of the old and new URLs in Prometheus:
- Request counts per URL version.
django-prometheusper-view metrics may already cover this; check the views have distinct names. - Which feeders are still on the old URLs, so we can chase their owners. Use either a low-cardinality counter labelled by feeder (the fleet is small) or a
last_used_legacy_url_atfield onManagedNode. Pick one.
- Request counts per URL version.
- Retire the old URLs once legacy usage reaches zero, or stays at a known handful we've contacted. This joins up with #319 (retire v1 ingest URLs).
- Once the old URLs are gone, enforce one key per feeder in the schema: a unique constraint on
NodeAuth.api_key, or move the key ontoManagedNode.
Open points
- A bot running both a Meshtastic and a MeshCore radio on one key: should the rule be one key per feeder per protocol, or one bot record owning both radios? Check prod for keys linked across protocols.
- Before step 6, find out how many prod keys are linked to more than one feeder:
NodeAuth.objects.values("api_key").annotate(n=Count("node")).filter(n__gt=1) - Dual-API (prod plus pre-prod) is unaffected, because each environment has its own key.
Acceptance criteria
- New feeder-scoped endpoints authenticate by key alone and reject shared keys with an actionable error.
- A feeder whose node number changes keeps ingesting on the new endpoints. Its number is updated, with the CRC check, an alias for the old number, and an owner notification. If ID-4 lands separately, at minimum there is no 403.
- Old v1/v3 endpoints behave exactly as they do today.
- New shared key links can no longer be created.
- Prometheus shows request volume for the old and new URLs, plus a way to list the feeders still on the old URLs.
- Bot change tracked in a linked meshflow-bot issue.
- Docs updated:
API.md,API_KEYS.mdand the ingestion docs.
- Dominant language
- Python
- Stars
- 1
- Forks
- 0
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 5
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pskillen/meshflow-api
-
enhancement meshtastic-2.8
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
pskillen/meshflow-api#459 ·
-
enhancement meshtastic-2.8
Difficulty 3/5 1-2 days Newbie friendliness 35/100
pskillen/meshflow-api#465 ·
-
enhancement meshtastic-2.8
Difficulty 4/5 3-5 days Newbie friendliness 22/100
pskillen/meshflow-api#464 ·
-
enhancement meshtastic-2.8
Difficulty 4/5 3-5 days Newbie friendliness 35/100
pskillen/meshflow-api#463 ·
-
enhancement meshtastic-2.8
Difficulty 3/5 1-2 days Newbie friendliness 45/100
pskillen/meshflow-api#462 ·
All issues in pskillen/meshflow-api
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
elviskahoro/sdk-python-attio#144 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
RenyiELBO raises TypeError when model has no sample sitesPossibly taken @alibb007 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
[Bug]: Four evaluation scripts unpack init_memmachine_params's five return values into three namesOpen
Difficulty 1/5 Under an hour Newbie friendliness 88/100
MemMachine/MemMachine#1911 ·
Maintainers usually reply within 3 days