Ver Fonte

docs: a key-gated function authenticates the caller and grants them nothing

Reported by novitax after gating their functions: they half-expected to need a
caller key carrying `search` on the collection the function reads, used a
least-privileged key with no collection rules at all, and found it works -
because the function still reads under its own policy. Nothing said so, and the
natural guess over-grants a credential that by design goes into a third-party
tool configuration.

Also records their rollout ordering, which is the better half: header into the
calling tool FIRST, confirm the key works against the still-ungated route, then
set auth: 'key'. Reversed, the route answers 401 until someone notices, and in
front of a voice agent that presents as "she does not know anything" rather
than as an auth failure.

This ships in the NEXT release, not 0.16.0 - that version is now published, so
republishing different content under it would be version reuse.

Prod follow-ups from the post-window verification, both done:
- runs_kept reported 50 despite 0.16.0 raising the DEFAULT to 500, because
  /etc/smartbotic-vectorapi/config.json pins it. Committed, released, deployed
  and still not EFFECTIVE - a fourth step on that ladder. Set to 500 and
  restarted; the API now reports 500. config.json was already locally modified
  before the edit (dpkg's shipped md5 00160b2e vs feae4f5e on disk), since the
  runner endpoint must be added by hand, so the edit adds no new conffile
  prompt risk.
- my own scratch project left the scheduler warning every 20s for a missing
  function registry. Creating a project ensures the COLLECTION registry, not the
  FUNCTION registry, so recreating it was not enough; materialised the empty
  collection. Arguably our bug: a project with no functions is normal and should
  not warn.
fszontagh há 1 mês atrás
pai
commit
8e7d4c5186
1 ficheiros alterados com 2 adições e 0 exclusões
  1. 2 0
      api/llms.txt

+ 2 - 0
api/llms.txt

@@ -396,6 +396,8 @@ export default async function (ctx) {
   - **An unrecognised value is REFUSED at push time** (`auth: 'kye'` fails the write), unlike an unknown KEY in the `on` block, which is still ignored so a script written for a newer server keeps loading. A typo must never publish a function its author believed was gated.
   - **On a server older than 0.15.0 this key is IGNORED and the function is public, silently.** That is the one place the forward-compatibility rule cuts against safety, so check the server version before treating `auth` as the only gate on something sensitive.
   - The key is used for the gate and is **not** forwarded to the function - `Authorization` has always been stripped - so a function cannot see, log or reuse the caller's credential.
+- **A key-gated function (`auth: 'key'`) AUTHENTICATES the caller and grants them NOTHING - so send your LEAST privileged key, not one scoped to the collections the function reads.** The function still reads and writes under its own stored policy, exactly as it does when public; the key only answers "may this caller invoke the route at all". A key with an empty rule set works and is the right choice. Worth stating because the natural guess is the opposite - that a function reading `kb_facts` needs a caller key carrying `search` on `kb_facts` - and guessing that way over-grants a credential that is, by design, going into a third-party tool configuration. Reported by a consumer who used a least-privileged key, found it worked, and pointed out that nothing said so.
+  **Order the rollout header-first.** Put the `Authorization` header into the calling tool, confirm it works against the still-ungated route, and only then set `auth: 'key'`. Reversed, the route answers 401 for however long it takes someone to notice - and in front of an assistant or voice agent that presents as "it does not know anything" rather than as an auth failure.
 - **The function's `rate_limit_per_min` policy now applies to CALLS on this route** (since 0.15.0), not only to the function's data access. `0` means unlimited, as everywhere else. Over the ceiling is **429** `rate_limited` with `Retry-After: 60`. Three things worth knowing:
   - **The two ceilings are counted SEPARATELY against the same number.** A limit of 60 means up to 60 calls a minute AND up to 60 data operations a minute; it does not mean a function doing three reads per call gets 15 calls. Adding a read to a script therefore cannot lower its own request ceiling.
   - **The ceiling is per FUNCTION, not per caller.** It bounds the DAMAGE - mail sent, paid API calls made, on the tenant's quota and sender reputation - rather than the denial: one abusive caller can still exhaust a public function's minute and shut out legitimate ones. Per-caller limiting needs an identity, which is what `auth: 'key'` gives you and an anonymous request does not have.