Globetrotter docsversion 0.3.0 · 2026-12-04

Auth and security

On this page
  1. Try it by hand
  2. Sign-in methods
  3. Real users in your database
  4. Roles
  5. Row rules
  6. A field only some roles may read
  7. Who sees every row of an owned entity
  8. Organisations (tenants)
  9. Actions that run another operation
  10. The environment
  11. Development credentials
  12. API keys
  13. The session cookie
  14. What the service guards
  15. CORS
  16. Sign-in rate limit
  17. Rate limits on operations
  18. What is the host's
  19. Audit
  20. Tools
  21. Before production
storefront on a phone: a stranger's order refused in words, a wrong password, the order placed once signed in
storefront on a phone: a stranger's order refused in words, a wrong password, the order placed once signed in

Storefront's shop is anyone's to browse; placing an order needs a member. The design says so in two words per operation (allow: anyone, allow: member), and the generated backend, the contract and the pages follow. The tools check it:

press_operation storefront Checkout.placeOrder               # as a stranger
401 Unauthorized  {"error": "Not signed in."}
press_operation storefront Checkout.placeOrder as=member     # the development key
200 OK  {"confirmation": "Order NB-1049 confirmed. …"}
get_audit storefront entity=order since=5m
2026-11-05 09:24:23  order NB-1049  created  by dev-member  (request press-3a17…)
check_auth storefront
Every answer agrees with the design's allows (25 presses, as a stranger and as member, admin; nothing was changed).

That run is from 2026-11-05. Storefront has since gained Orders (a member reads their own orders, by the order's owner; an admin reads every one) and Reports.sales (an admin's), so check_auth checks more than 25 now.

Try it by hand

The tools above are an agent's. Without one, edit the design, run sync and call the server with curl. On the quickstart's project, add this beside entities and services in designs/my-api.service.json:

"auth": { "types": [ { "kind": "session" }, { "kind": "apikey", "header": "X-Api-Key" } ],
          "roles": ["member", "admin"] }

sync now fails: error · operation-unprotected: Items.list names no role, so with sign-in on nobody may run it … and 6 more alike. Give each operation an allow in its props ("allow": "anyone", "member" or "admin"), sync again, run uv sync in backend/ (sign-in adds Python packages), and start the server as local:

$ curl -s localhost:8000/items                       # allow: anyone
[{"id":"…","title":"Write the docs","done":false}]
$ curl -si -X POST localhost:8000/items/actions/create -H 'content-type: application/json' -d '{"title":"x"}'
HTTP/1.1 401 Unauthorized
{"error":"Not signed in."}
$ curl -s -X POST localhost:8000/items/actions/create -H 'X-Api-Key: dev-member-key' \
    -H 'content-type: application/json' -d '{"title":"x"}'
{"item":{"id":"…","title":"x","done":false}}
$ curl -s -X POST localhost:8000/notes/actions/shout -H 'X-Api-Key: dev-member-key' …   # allow: admin
{"error":"Signed in, but below admin."}
$ curl -s -X POST localhost:8000/notes/actions/shout -H 'X-Api-Key: bad' …
{"error":"That API key is not one this service knows (sent in X-Api-Key)."}

Signing in with a password is POST /session/actions/signIn (POST /session is a 405); the answer sets the gt_session cookie:

$ curl -si -X POST localhost:8000/session/actions/signIn -H 'content-type: application/json' \
    -d '{"email":"member@example.com","password":"dev-member"}'
HTTP/1.1 200 OK
set-cookie: gt_session=…; HttpOnly; Max-Age=1209600; Path=/; SameSite=lax
{"signedIn":true,"id":"member@example.com","role":"member"}

Seven wrong passwords for admin@example.com in a row answer 401 five times, then 429 (retry-after: 60, Too many failed sign-ins: try again in 60 seconds.); the right password is refused too while the window holds, and member@example.com still signs in.

An email or a password with a NUL, or an email past 255 characters, is a 400 before any account is read (transcript, its last lines). A managed key's name and a text organisation key are bounded the same.

uv run pytest signs in as the top role by itself, also on this design (a session and an apikey sign-in together): the run's key goes beside each case that carries a credential, so Schemathesis knows it is the run's own and checks that the same case without it, and with a made-up one, is refused.

Sign-in methods

The design's auth.types lists the sign-in methods. They are tried in the order listed. A wrong credential is a 401 everywhere. No credential is a stranger.

Kind What it is
session A signed cookie. Adds /session, sign in and sign out to the contract.
apikey A key in a header, for a machine. Which keys there are is your key store's to say: API keys.
oidc A bearer token checked against the issuer's keys.
jwt A token the service issues for an email and a password.
magiclink A link sent by email that signs in once. Needs a session or jwt to keep the person in.
passkey WebAuthn. Needs a session or jwt to keep the person in.

Settings for each are in the reference. The Rust target writes session, apikey, jwt, oidc and magiclink; passkey is Python only. If a design turns on a sign-in method and no page offers it, lint says so; the sign-in page template is one (add_page and create_design both take it).

Real users in your database

Sign-in by session, token or link checks people against a store. Without more, that is the development people and GLOBETROTTER_PEOPLE. The accounts block keeps them as rows of your own database instead (Python target only: the Rust target refuses a design that applies the block, as target-unsupported on the account entity, because passwords are stored as scrypt so that both targets can verify them on one database, and the Rust build has no scrypt crate in its shipped lockfile or offline cache; it never writes a sign-up that stores nothing usable):

set_auth(design, types: ["session"], roles: ["member", "admin"])
use_service_block(design, "accounts")            # at: an entity of yours to adopt it; service: where signUp goes
POST /accounts/actions/signUp {"email": "ada@example.com", "password": "…"}   # 200, or 409 when the email has an account

It adds an account entity (a unique email, kept lower case; a passwordHash marked sensitive, which no contract schema, answer or audit row carries; a role of the ladder; passwordChangedAt) and two commands: Accounts.signUp, open to anyone, 5 a minute per address, which makes a person at the lowest role (409 for an email that has an account, or that a development person holds: one answer for both), and Accounts.changePassword (signed in: the current and a new password). The contract marks each password format: password and writeOnly. The password is kept as a salted scrypt hash (the standard library: no new dependency; a stored value of any other form or cost is not read, and signs nobody in). Every hash runs off the event loop, four at a time, and a wrong email costs the same time as a wrong password. The 429 after repeated failures applies per email, and failures from one address are counted whatever emails they name (GLOBETROTTER_SIGNIN_ADDRESS_MAX, 20 a minute). A person's id is their email, so an owner rule compares with it.

Emails are not verified. Apply email-verification (at the account entity) before rows are owned by email: whoever signs up with an address first would own every row keyed to it. Lint warns (accounts-unverified-owner) when a design has accounts and an owned entity and no verification. With the block applied an account counts for sign-in only once its email is confirmed (a 401 until then, the same words as a wrong password) and askVerification is open to anyone, since an unverified person cannot sign in to ask; it sends only to an address an account holds. Accounts that exist when it is applied start unverified. Write the notice's sending in AccountsImpl.ask_verification.

The development people stay behind the rows in local only, so check_auth and the tests can sign in as each role. Outside it GLOBETROTTER_PEOPLE is not read (the server says so at start if it is set), so no address of a person from the environment can be signed up for, and the server starts with the session secret alone. The first admin is a row whose role you set by hand.

A password change ends the sessions made before it (changePassword, and password-reset's recipe through accounts.set_password): the session cookie carries its time and a token its iat, and either is refused (nobody signed in) when the account's passwordChangedAt is later. A cookie from before the block has no time and ends at the first change, so apply the block to a new project, not to a deployed one with live sessions. The change takes effect to the second for a token; the caller signs in again. data import of account rows refuses a hash this service cannot read and lower-cases the email. The reset link's token is 32 random bytes, kept only as its sha-256, used once by one conditional update and expiring (an hour for a reset, a day for a verification).

Roles

auth.roles lists roles from low to high: member, admin. An operation's allow names the lowest role that may run it. anyone opens it to strangers. There is no deny. The check runs before a body is read (Casbin in Python, a Cedar policy set in Rust). Below it is a 403, not signed in a 401.

With sign-in on, an operation that names no allow is refused to everyone; lint's operation-unprotected says so with a fix.

There is one order of roles per service design. A role is a level, not a bag of permissions (limits).

A ladder of API keys, with the pages left open

Fieldops has no sign-in page. Its design signs in by API key only, with three roles, and says allow: anyone on the operations its three pages call, so the pages work signed out. What is beside the pages asks for a role:

"auth": { "types": [ { "kind": "apikey", "header": "X-Api-Key" } ],
          "roles": ["technician", "dispatcher", "admin"] }
$ curl -i localhost:8011/work                                                   # allow: technician
401  {"error":"Not signed in."}
$ curl -i localhost:8011/                                                       # the Dashboard's data, allow: anyone
200
$ curl -X POST -H 'X-Api-Key: dev-technician-key' …/work/actions/finish/j3     # the technician's move
200
$ curl -X POST -H 'X-Api-Key: dev-technician-key' …/work/actions/reopen/j3     # the dispatcher's
403  {"error":"Signed in, but below dispatcher."}

The whole run: work-transcript.txt, and the same on Rust: rust-fieldops-work.txt. The studio's Permissions view names the operations open to a stranger on purpose. A key that is sent must still be a good one. An update is checked like a create: a wrong value in what is sent is a 400 and nothing changes (Reference).

Row rules

An entity's owner field names the person a row belongs to. Each person then reads and changes only their own rows, and the highest role sees every row. Another person's row is a 404. In Rust the owned rows are a WHERE.

An entity with no owner has no row rule: a member who may run an update may run it on any row. In one test, bo changed ann's order, and the audit said so. Give the entity an owner for a row to be its person's alone. Lint's owner-not-applied says when the owner names no field, or sign-in is off.

A field only some roles may read

A field can say who may read it: readFrom: <role> on a Field (set_service_props, or Field's "Only read by"), the lowest rung of the ladder, as allow names the lowest rung that may run an operation. Patient.notes with readFrom: clinician is meant to work like this:

  • A caller below clinician gets the row without the property: absent, not null (null means "empty", absent means "not yours to see"). On every read: get, list, a nested row, the <Entity>Linked twin, search, an export, what a create or update answers, and the audit log's row images.
  • They cannot write it: a create or update naming it is a 403, "Only clinician and above may set Patient.notes: it is kept from anyone below clinician."
  • They cannot probe it: ?notes=cancer, ?sort=notes or a search naming it is a 403, not fewer rows; the q search simply does not read it for them.
  • The contract has the property in the row, not required, marked x-globetrotter.readFrom, and documents the 403.
  • Refused when it cannot hold: sign-in off, anyone, a role not on the ladder, with sensitive (never returned: choose one), on the key, the owner field, a field a where keeps to =me by. A where or fixed sort that names it makes the whole query need the role (read-from-where).

What the pages do with it. A page draws a kept field only when it was given. The generated types make it optional (notes?: string); a line that reads only kept fields (a record's "Notes" label over its value, a row's trailing text) is drawn when the property is there, and never as "None" (None means empty; absent means not yours to see, and "Notes: None" would say there are no notes). An input bound to one is drawn for a role that may set it (the page asks the session's role, can(role)); until the session is known it shows, and the service's 403 says why under it. A Shape that reads a kept field is a lint error (read-from-shape): a total cannot leave it out, so the query needs the role.

Whose role decides. For an entity whose rows belong to an organisation the caller's role in the acting organisation decides, as allowIn does: the same person is a clinician in one practice and a receptionist in another, and reads the notes only in the first. No acting organisation means below every role. For an entity with no organisation the person's own role decides. A command whose sets names the field writes it on every run, so that command needs the role as a whole (lint read-from-sets is an error while its allow is below it); a param named like the field is refused 403 for a caller who names it, on every command kind.

The Python target serves it; the Rust target refuses it at sync (target-unsupported: it would give the field to every caller). The Python target's cache keeps an answer by the person, the acting organisation and the role that decides.

What still carries the field. Event and webhook payloads, the access log's query strings, and the audit and export command lines run as the operator, who has the database: they show it (--as <role> reads as that role, and the export says it carries a kept field). A composite unique index that holds the field can confirm a value through a 409.

What else exists: sensitive on a Field (get_catalog for Field lists it) keeps it out of every answer, schema, audit row and trace for everyone, which is right for a hash and wrong for "clinicians only"; a Shape (returns) is a different typed answer, but it is counts and sums, or yours to write, not a row with fields left off.

The pattern that works today is the sensitive part is its own entity with its own allow. Notes only clinicians and above may read: not a notes field on patient, but a patientNote entity (body, and a relation patient), in its own service whose list, get and add say allow: clinician, while Patients.list and Patients.get say allow: member:

add_entity(design, "patientNote", fields: [{name: "body", type: "text"}])
add_service_node(design, "Relation", "patientNote", {name: "patient", to: "patient"})
add_operation(design, "PatientNotes", "Query", "list", {many: true, returns: "patientNote", allow: "clinician"})

The record page then draws the patient's own lines for every role and the notes as a nested list ("Patient notes", kept by the patient), which a member's request answers 403: that section shows its failed state, not the rows, and the rest of the page loads. check_auth presses each operation as each role, so the split is checked, not trusted. With organisations, give the notes the same organisation scope as the patient. This split is the way that works on a target that does not serve readFrom (Rust): on Python one entity keeps its fields in one row.

Who sees every row of an owned entity

An entity with an owner shows each person their own rows, and today only the highest role sees every row. A school library whose Loan is owned by its borrower and whose ladder is member < librarian < head shows a librarian only the loans they borrowed themselves: Loans.list, overdue and the overdue count answer empty although each says allow: librarian. Lint says it:

owner-hides-rows: Loans.overdue lets librarian run it, but Loan's rows belong to
their borrower and only head sees every row: a librarian will see only the loan
rows they own themselves (a list, a count or a record that is not theirs comes back
empty or not found). If librarian should see every one, set Loan's seesAll to
librarian (the lowest role that sees every row); if they are meant to see only
their own, lower the operation's allow to member.

seesAll: librarian on the Entity ("Sees every row") says the lowest role that is given every row: a librarian and a head read every loan, a member still only theirs. Unset it is the highest role, as before; the lowest rung of the ladder (everyone signed in) is never warned about, as "my own rows" is what an operation for them means. It needs an owner (refused otherwise), sign-in on, and a role of the ladder; for an entity that belongs to organisations it reads the role in the acting organisation and must be one of the organisation's roles. The lint's Fix sets it to the operation's allow.

Seeing every row means reaching every row: an update, delete or transition a role may run reaches them too; keep such operations' allow where you want it. The generated tests/test_sees_all.py presses it: a librarian may return another's loan where the operation admits librarian, a member may not touch another's (404).

What is generated. The Python target serves seesAll (and readFrom): its test_sees_all.py presses it. The Rust target does not write either yet, so a design that uses one is refused at sync with a sentence naming the target (target-unsupported, features owner-sees-all and field-read-from); nothing else changes.

Organisations (tenants)

When people belong to organisations, say so once and every row follows. The design gets a tenancy section, the organisation, the membership (who is in which organisation, with what role) and a scope on each entity; operations say the lowest role in the organisation that may run them (allowIn) beside allow, the person's own role. Reference has the keys.

A request Answer
Names no organisation 400 Say which organisation: send X-Org.
Names one that does not exist, or one the person is not in 404 No organisation has that id. (the same for both)
Is in the organisation, below the operation's role 403 Signed in, but below owner in this organisation.
Is a member with a role high enough Runs, and sees only that organisation's rows
Is the top global role, with staffSeesAll on Passes any organisation; naming none, sees every row

On a fresh project in the local environment nobody is in an organisation yet, so a person who signs in sees nothing and check_auth has nobody to press as a member. GLOBETROTTER_ENV=local uv run python -m <app>_core.devseed (from backend/) makes the organisation dev with each development person in it at a role of the organisations, the lowest person at the lowest and the highest at the highest, and dev-other with the lowest person alone, so everyone else is a stranger to it. Run twice it adds nothing; in any other environment it says so and writes nothing, with no flag to override that; a database that already has an organisation of its own is left alone unless you add --anyway. It writes only into a database on this machine (localhost, 127.0.0.1, ::1, a unix socket or a sqlite file) and says which host it refused, with no flag to override that. Its keys are fixed: a uuid, a negative whole number (so a real row's counter never meets them), or the words dev and dev-other; a real organisation keyed dev or dev-other under another name is refused, --anyway or not.

The Rust target has the same seed and answers alike: GLOBETROTTER_ENV=local cargo run -p <app> -- devseed (from backend/, --anyway as above). globetrotter dev prints the command for the default target when organisations are on, and the studio's Status names it when check_auth was not a pass for want of these people.

The generated tests make their own two organisations and memberships in the test database (not the development seed), name the first on every request and create rows in it. Skipped cases are listed by -rs (Python) and cargo test -- --ignored --list (Rust, where a case it cannot make is an #[ignore = "why"] test, never an omission).

Pressed Must answer Where
A move naming no organisation 400 in the design's words test_transitions.py; Rust tests/machines.rs
A move as a member one rung below its allowIn 403 the same
A move on a row of the other organisation 404 the same
Every list of an organisation's rows, a row in each organisation this organisation's row, not the other's test_tenancy.py; Rust tests/tenancy.rs (key, session and token sign-in; a uuid, string or whole-number organisation key)
Every get of the other organisation's row the row's own 404 the same
Naming none, or one the person is not in the organisation's refusal the same
Every update, delete or move on a row of the other organisation (a valid body), and every create the row's 404, the row and its audit rows and events unchanged; a create lands in the organisation named; a member one rung below its allowIn is a 403 in the role's words (at the rung, through); with staffSeesAll the top role who is not a member sees both organisations' rows and a lower non-member is still refused, without it the top role is refused like anyone test_tenancy.py presses the update, delete and move for every sign-in (naming the person's own organisation, then one they are not in), a create only under an API key; the same, and Rust tests/tenancy.rs for every sign-in and key kind

Your crate's once-written crates/<app>/tests/tenancy.rs presses the same with your services wired in, so a list of yours that reads every organisation, or an update that finds the row around the scope, fails there (its //! Presses: and //! Writes: lines are what sync compares with the design once you have edited it). check_tenancy finds the code that goes round the scope.

check_auth presses organisations too. Each operation that runs in one is pressed as a person naming none (refused), as a member at each role of the organisation (let through from allowIn up, refused below) and as a member of another organisation naming this one (refused). A list or get of an organisation's rows with no allowIn is pressed for what it leaks: a member of its own organisation, a person naming one they are not in and none named (all refused), and a member of another asking for a row of this one (404). Rows of another organisation in a list are said, never passed by silence. When nobody is in an organisation (run the seed above), or a read had no rows to read or an answer that is not rows carrying their organisation, the head says "this is not a pass" and names what was "not read", and the run is not kept as the last check. It does not press an update or delete across organisations by session (Limits).

A person in two organisations sends the one they mean in X-Org, or chooses once (POST /tenancy/actions/select sets the cookie; GET /tenancy lists their organisations and roles). The cookie is not a credential: the membership is checked again on every request. Another organisation's row, asked for by its id, is a 404; a create's body that names an organisation (organisationId) is a 400, as any field the operation does not take, and the row is made in the current one; a link to another organisation's row is a 404. The audit row, the event and the flow's step all carry the organisation.

The scope is in the repositories. Your code that asks for every row (every=True, the Rust _every methods) or writes SQL of its own is not scoped: check_tenancy lists those places by file and line. On postgres, tenancy.rls adds row-level security as a second guard that covers raw SQL too, and your own every reads, on the tables of the entities that say scope: rows (the jobs, tasks and the like). It does not cover the membership, the organisation entity, audit_log, API keys, the outbox, the flow tables or a many-to-many join table: raw SQL on those is guarded by nothing but your care (check_tenancy still finds it). The migration writes ENABLE and FORCE ROW LEVEL SECURITY, so a table's owner that is not a superuser is bound too. It binds no superuser and no BYPASSRLS role, and the Postgres image's own POSTGRES_USER (the compose database's fieldops) is both; a table's owner can also ALTER TABLE ... NO FORCE or drop the policy. So at start, with tenancy.rls on, each target asks Postgres about its own role (rolsuper, rolbypassrls, and whether it owns a table with a policy). In production (anything but GLOBETROTTER_ENV=local) the API serves no request until that check has passed: a superuser, a BYPASSRLS role or such an owner is refused with one sentence naming it, and a database that cannot be asked (or a role it does not name) is never taken as bound: the start waits for it for up to 30 seconds, then refuses. Locally it says the same once, or that the check could not run, and starts. Membership in a superuser role (SET ROLE) is not detected. The migration runner is not asked: it may be the owner or a superuser. Each unit of work sets app.org for its transaction, so a pooled connection never carries one request's organisation into the next, and a read that names none sees no rows.

The all-zero key (the nil uuid, 0, empty text) is nobody's: it is what a row with no organisation reads as, so a request naming it is a 404 as a malformed key is, a create of the organisation with it is a 400, and (Rust) a row with no organisation is held by no organisation whatever key the caller has, with rls on or off, on SQLite and MySQL too.

To run bound, serve as a role that is not a superuser and lacks BYPASSRLS, and migrate as the owner. When a design has rls, the generated compose.yaml makes <app>_app on the database's first start (compose.rust.yaml does the same: RUST_DB_APP_URL is its own variable for the address) (DB_APP_USER, DB_APP_PASSWORD; default password a development one) and gives it the tables the owner makes later; migrate runs as the owner, api, relay, worker and scheduler as that role. Locally, outside compose, export the app role's URL (GLOBETROTTER_DB_URL=postgres://fieldops_app:...) for the API; a volume made before rls was on has no such role (docker compose down -v, or the statements in the migration's NOTE). A seed or backfill that you write for these tables and run as a bound role sees none of their rows and may insert none: run it as a superuser or BYPASSRLS role, or set_config('app.org', ...) in its transaction.

Bound, three things see no rows through those tables, because nothing sets app.org for them: the top role with staffSeesAll naming no organisation; a scheduled job, or a script, outside any request; and a flow step whose event carries no organisation. (A flow step whose event carries one, the usual case, enters it and works as the bound role; the compose worker and scheduler run as <app>_app.) To have them see rows, name an organisation (the staff person sends X-Org; a job does its work inside the organisation it is for), set app.org in the transaction, or run that process as a BYPASSRLS role. Nothing warns of it at start; limits.md and deploy-and-operate.md say the same.

Turning organisations on over rows that exist: the migration adds organisation_id allowing empty values and does not choose one for the rows already there. A row with no organisation is in none, so no member sees it: a list leaves it out, a read, update or remove by its id is a 404 (a remove of one that jobs still point at is the 409 those jobs earn), and it is not shown under its parent. It never answers a 500. Assign each one by hand as the migration's NOTE says, as a superuser or BYPASSRLS role, since a role the policy binds does not see them; sync prints that NOTE. staffSeesAll, naming no organisation, reads every row, those with none too (not as a role the policy binds: that reads none); such a row answers with the all-zero organisationId (no organisation has it), the same on both targets. Run on Postgres 16 on both targets: transcript.

Where a request names its organisation is tenancy.from: a header (always read first), a cookie, or a token's claim. The claim is Python's alone, needs a jwt or oidc sign-in, and was never run with a real token; Rust refuses it in lint.

Actions that run another operation

A page action can name the operation it runs (describe_action … calls: Session.signIn, or Runs in the inspector). A sign-in page then posts to the session, and the contract has no empty path for it.

The environment

GLOBETROTTER_ENV names the environment. Only the exact word local turns on what is meant for a developer's machine: the /docs and /redoc pages, the exception and line in a 500's body, the development credentials below, the development secrets, and a reload on a change. Unset, or any other word, is production: none of those, and a missing secret is a refusal to start.

Unset is not local. With GLOBETROTTER_ENV unset the service looks for an environment named production (designs/components.production.json), and without one it stops with GLOBETROTTER_ENV is not set and the names it knows. globetrotter dev, npm run dev:* and the generated tests set local themselves; a command you run by hand needs it:

$ GLOBETROTTER_ENV=local uv run python -m <app>_fastapi

Development credentials

On local only, with nothing set:

What Value
Person to sign in <role>@example.com, password dev-<role>
API key dev-<role>-key

With the accounts block, outside the local environment an address at a reserved domain (example.com, .org, .net, .example, .test, .invalid, .localhost: no real person has one) is no account on any path (sign-in, sign-up, a link, a token): it is answered as a wrong password and the log says so once. The start says, loudly, how many such rows the table holds (a restored development database, or devseed run against the wrong one): delete them. devseed itself says where it writes, wants --yes in a database server, and exits 1 when it wrote nothing.

They live in <app>_impl/auth.py (DevPeople, DevKeys), which is yours to replace. Outside local, only what GLOBETROTTER_PEOPLE (email:role:password) and GLOBETROTTER_API_KEYS (id:role:key) name can sign in, so no built-in key or person ever reaches production. What a server then refuses to start without is the same on both targets: outside local, when every way in the design offers lacks its own (no GLOBETROTTER_API_KEYS for apikey, no GLOBETROTTER_PEOPLE for magiclink, no issuer for oidc; a session cookie and a jwt are checked by their signature, so they need only their secret) and no operation is allowed to anyone, the API stops at start with one line naming the variable and what it holds. When one way in works and another does not, or an operation is open to anyone, it starts and says the missing one once on stderr; /ready answers 503 for a chain that cannot be set up. A session, token or link secret and the passkey secret are refused on their own. The worker and scheduler sign nobody in and are not refused. People kept in a table are your own store (below): a store of yours that does not say it is empty is taken to hold somebody, so it is never refused for the variable (on Rust the store goes in your main.rs through AuthChain::new and AuthChain::start; the Rust worker was not run for this). A password is kept only as its scrypt hash, and a wrong email takes as long as a wrong password to answer.

DevPeople is an in-process list read from an environment variable. For real accounts (a table, a vault, an identity provider) write your own store in auth.py: the generated chain only asks find(key) and check(email, password). Passkeys are kept in memory on a laptop and never in production, where a table keeps them.

API keys

Without more in the design, a key is whatever the key store in <app>_impl/auth.py knows: the development keys on local, GLOBETROTTER_API_KEYS (id:role:key) elsewhere, or a store you write. Such a key has a role and nothing narrower, and does not expire.

With keys: "managed" the service keeps its own keys: people make, scope, rotate and revoke them at /apikeys, and the service stores a hash, never the key. Concepts shows it; Reference has the settings and each message; Targets says where it has been run. To call an operation as a key without making one by hand, use An API key in Try it or press_operation with as: "key" (Studio: Keys).

What a key is answered, the same on both targets:

Status Word When
401 keyUnknown The key is unknown, or its secret is wrong (one answer for both).
401 keyExpired, keyRevoked The key is past its life, or was revoked.
401 keyRoleGone The key's role is no longer on the ladder.
403 keyNoScope The key has scopes, and not the one the operation names.
403 keyUnscoped The key has scopes, and the operation names none.
403 keyElsewhere The request names an organisation other than the key's.
403 keyCannotMake A key calls one of the /apikeys paths.
404 notMember The key's maker is no longer in its organisation.
409 keyGone A rotate of a key already rotated or revoked.

What a person making, rotating or revoking a key is answered:

Status Word When
403 keyBelowMake The person is below the role that makes keys.
404 keyNotYours The id is not a key of theirs.
400 notOneOf, on scopes A scope the design does not list.
400 atLeastN, atMostN, on expiresIn A life under a minute, or over the design's. 0 (no end) is taken only where the design's keys never expire.
422 keyAbove A role above the maker's own sign-in role.

A rotation is never refused for the role, so a leaked key can always be rotated: the new key has the lower of the old key's role and its maker's sign-in role now, and lives as long as the old one was made to.

A key limited to its scopes is refused an operation with no scope. From the Rust run (transcript):

$ curl -i http://localhost:8946/ -H 'X-Api-Key: fo_5a960eb456e679ea_<secret>'
HTTP/1.1 403 Forbidden
{"error":"This key is limited to its scopes, and Dashboard.list names none of them: call it signed in, or with a key that has no scopes."}

A key's role in an organisation

A key's own role is on the sign-in ladder, and is checked against its maker's sign-in role when it is made (422 keyAbove). In an organisation the key acts at its maker's role there now, read on every request:

The maker in the key's organisation The key
Lowered Lowered at once, with no rotation.
Raised Raised too, up to the key's own role where both ladders name it.
Removed Refused as the maker would be: the 404 below.

The key's own role lowers it further only when that role's name is also one of the organisation's roles. Where the two ladders share no name, only scopes narrow a key in an organisation; lint's apikey-org-unscoped says so when the design lists none. From the Rust run, a key made by a member who could create jobs:

$ sqlite3 db.sqlite "update membership set role = 'viewer' where user_id = 'member@example.com' and org_id = '<Acme>'"

$ curl -i -X POST http://localhost:8947/jobs/actions/create -H 'X-Api-Key: dp_f6086f83974851bd_<secret>' -d '{"title":"Boiler 2"}'
HTTP/1.1 403 Forbidden
{"error":"Signed in, but below dispatcher in this org."}

$ sqlite3 db.sqlite "delete from membership where user_id = 'member@example.com' and org_id = '<Acme>'"

$ curl -i http://localhost:8947/jobs -H 'X-Api-Key: dp_f6086f83974851bd_<secret>'
HTTP/1.1 404 Not Found
{"error":"No org has that id."}

One key answers the same on both targets on one database, organisations included (transcript).

If you keep your own store instead:

  • Give a machine a key of the lowest role that does its work.
  • Rotate by adding the new key to GLOBETROTTER_API_KEYS, moving the caller, then taking the old one out. Each step is a restart.
  • It is signed, not stored. Sign-out clears the browser's copy; a copy taken from it stays good until it expires (14 days by default) unless GLOBETROTTER_SESSION_SECRET changes, which signs everyone out.
  • With GLOBETROTTER_PEOPLE the role travels in the signed cookie, so changing a person's role takes effect when their cookie expires, while the accounts block reads the role from the row on every request.
  • It is HttpOnly and SameSite=Lax, so a form on another site cannot post with it. It is Secure outside local, whatever the scheme looks like from behind a proxy that ends TLS.
  • An expired cookie is no one: the open pages still work, nothing is refused for it. One with a wrong signature is a 401.
  • Outside local the secret must be set, or the service says so in one line and does not start. There is no built-in secret outside local.

What the service guards

Generated and in force:

  • A body over 2 MB is refused with 413 before it is read on (GLOBETROTTER_MAX_BODY sets another; uploads have their own block's size).
  • A field the contract does not name is refused.
  • A short text field's longest length is the design's; lint says when one has none.
  • A wrong email and a wrong password are answered alike, in the same time.
  • Every answer carries X-Content-Type-Options: nosniff, X-Frame-Options: DENY and Referrer-Policy: no-referrer; outside local also Strict-Transport-Security: max-age=63072000; includeSubDomains.
  • An answer to a request that carries a cookie, an Authorization header or an API key is Cache-Control: no-store, unless the route set its own.
  • Refusals say nothing about the server: no server header, a 500's exception and line only in local, /docs only in local.
  • Every write to an audited entity leaves who did it.
  • Secrets are names in a design and components files, never values; a credential written into either is refused.

CORS

Off by default: no Access-Control-* header is sent, so a browser on another origin cannot read an answer. Set GLOBETROTTER_CORS_ORIGINS to a comma list of origins to allow them:

GLOBETROTTER_CORS_ORIGINS=https://shop.example.com,https://admin.example.com

Those origins may send the cookie (Access-Control-Allow-Credentials: true) and the headers Content-Type, Authorization, X-Request-Id and each API key header; every other origin gets no Access-Control-Allow-Origin, so the browser withholds the answer. * is refused at start, because credentials and a wildcard together are never allowed. The pages in this repo reach the service through a same-origin rewrite and need none of this.

Sign-in rate limit

Wrong passwords are counted per client address and email, on the session and token sign-ins. After 5 failures the next attempt is answered 429 with Retry-After, right password or not. A right password clears the count; a different email counts alone. The message is Too many failed sign-ins: try again in {n} seconds.

The design The window Where the count is kept
Uses rate limits (a limits section or an operation's limit) Fixed: the clock's minute. The 429 lasts until that window ends, and limits.signIn (5/minute when left out) sets the number and the window. The limits' counter: one process's memory, or the redis store limits.store names, shared by every process.
Does not Sliding: 60 seconds from each failure. The 429 lasts until the oldest failure is 60 seconds old. One process's memory. Each worker or replica counts alone, and a restart forgets.
Variable Default
GLOBETROTTER_SIGNIN_MAX_FAILURES 5; 0 turns the limit off
GLOBETROTTER_SIGNIN_WINDOW_SECONDS 60

The variables win over limits.signIn. The design cannot turn the limit off. The address is the connection's: behind a proxy it is the proxy's, unless uvicorn is told to trust its forwarded headers.

Rate limits on operations

Sign-in is the only thing limited unless the design says more: Concepts, Reference.

What is the host's

Yours, in front of the service or in auth.py:

  • TLS.
  • A limit that holds across workers and replicas where the design names no limits.store, and lockouts by account.
  • Request timeouts and IP rules.
  • Who may sign in at all.

Audit

Each create, update and delete of an audited entity made through the ORM leaves a row in audit_log in the same transaction as the change:

  • who: the signed-in person's id, or a key's id (name a key after its person, ann@example.com:member:…, so their rows read as one);
  • the request id, the entity and the row;
  • the operation that wrote it;
  • the fields before and after (audit: changes; full keeps the whole row; a sensitive field is never kept).

A personal field's value is not kept. Where the row had one the audit holds "[personal]", and null where it had none, so set and emptied still read. A changed address reads "[personal]" on both sides: the row says the field was touched, by whom and when, not what it was.

Audit on fieldops after an email change: the value is not kept, the row says personal, not kept
Audit on fieldops after an email change: the value is not kept, the row says personal, not kept
$ sqlite3 db.sqlite "select action, before, after from audit_log where entity = 'technician' order by at"
update|{"name": "Noor", "email": "[personal]"}|{"name": "Noor K", "email": "[personal]"}
update|{"email": "[personal]"}|{"email": null}

A field named in auditFields (with audit: fields) keeps its value: naming it is the choice to keep it. The key is never marked. An event's payload is not marked. Both targets write the same rows (python-audit-personal.txt, rust-audit-personal.txt).

The row names what wrote it: a command as Service.operation, a scheduled job as job:<Job>, a flow's step as flow:<Flow>.<step>, a webhook's handler as webhook:<Webhook>. Rows kept before the column was added say none:

$ sqlite3 db.sqlite "select entity, row_id, action, coalesce(operation, '(none)'), request_id from audit_log order by at"
job|j3|update|(none)|01a1da83-b518…
job|j3|update|Work.assign|01a1da84-003f…
job|j3|update|Work.assign|01a1da84-003f…
technician|0190a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a02|update|Technicians.update|01a1da84-0056…
job|j3|update|job:flagOverdue|

$ uv run python -m fieldops_core.audit --entity job --row j3 --limit 3
2026-11-14 08:44:07  job j3  updated  by no one signed in  via job:flagOverdue  (request none)
    status  Open → Overdue
2026-11-14 08:44:06  job j3  updated  by dev-dispatcher  via Work.assign  (request 01a1da84-004d-71b1-a108-510d56b75520)
    technician  Sam → Unassigned

Some rows are left out above; the whole run is in python-audit-operation.txt. Rust's reader says by dev-dispatcher, Work.assign, and both targets wrote the same values on one sqlite file (the 2026-11-14 part of rust-audit-personal.txt). A flow step's and a webhook's row read the same on both targets, principal included (flow onJobCompleted.noteDone, webhook:field: Python, Rust). On Postgres the rows were read from fieldops' Python backend and its Rust crate, whose reader prints the same via <operation> (Python, Rust), and on MySQL 8.4 from the Python backend (transcript). A project made before 2026-11-14 gets the column from a migration sync writes.

A body's own later write in the same request is a second row under the same request id and the same operation: fieldops' Work.assign leaves the link, then the shown technician text its body writes, and get_audit request=<id> gives both (python-audit-second-row.txt). A field set to the value it already had is not in the row, so a second press in the same minute leaves updated out.

Each row says what wrote it in operation: the command (Orders.cancel), a flow's step (flow:onOrderCancelled.restock), a job (job:flagOverdue) or a webhook (webhook:payments); a row kept before the column says nothing. Who (principal) is the person for a command and the flow or webhook itself for its own writes (flow onOrderCancelled.restock, webhook:payments), on the request that started it inline or on the event the worker ran, so a cancel and the restock it set off share a request id (python-audit-operation.txt):

order|NB-1042|update|Orders.cancel|dev-admin
product|p1|update|flow:onOrderCancelled.restock|flow onOrderCancelled.restock
order|NB-1042|update|webhook:payments|webhook:payments

A removed row's last audit row holds what it was and who removed it.

Take history out as a file:

$ uv run python -m <app>_core.audit --row NB-1044 --json

--csv writes one line per field that changed. A row's, one person's or one request's history comes out this way. check_audit names every write that goes around the ORM, by file and line, where the audit cannot see it.

What it does not prove.

  • Tamper evidence. audit_log is an ordinary table, append-only by convention, with no hash chain or signature. An engineer with the database can change it without trace. If a regulator needs more, keep that table under the database's own privileges and its backups or WAL archive.
  • Retention. The generated code never prunes audit_log, flow_run or the outbox's done rows; they grow with the service. A job of yours may archive them.
  • Reads. They are not recorded.

The traces file keeps the newest GLOBETROTTER_TRACES_KEEP spans, and the console sender's sent.jsonl the last 500 notices. Outside local the console sender keeps no notice and masks the recipient in the log.

Tools

Tool Does
press_operation Calls one operation as a role or a stranger and shows the audit rows it left.
check_auth Calls every operation as a stranger and each role, and compares each answer to its allow.
check_audit Finds every write to an audited entity that goes around the audit.
get_audit Says who changed what, filtered by entity, person, request or time; with org, in one organisation (Python target only).
set_auth Turns sign-in on, changes or turns it off; with tenancy (or tenancyOff) the organisations section. tenancy makes the organisation and membership entities when the design has neither; tenancyOff takes every scope, allowIn and grants too.
add_entity with scope Makes an entity that says whose rows it holds: tenant, membership, rows or global.
check_tenancy Finds every place your code gets round the organisation scope (every=True, _every, raw SQL), by file and line. service_status says the last run.
press_operation with org Calls an operation in an organisation (its id), as the person's key belongs to it.

Before production

  1. Set GLOBETROTTER_ENV to a real environment. Unset is production, not local.
  2. Set GLOBETROTTER_SESSION_SECRET (and the JWT, link, passkey and file secrets you use) to long random strings.
  3. Replace the development credentials: set GLOBETROTTER_PEOPLE and GLOBETROTTER_API_KEYS, or write real stores in auth.py.
  4. Put TLS in front of it. If it runs on more than one process, name a redis store in the design's limits section or put a shared rate limit in front. Never set GLOBETROTTER_LIMITS=off there. Set GLOBETROTTER_CORS_ORIGINS if a browser on another origin calls it.
  5. Run check_auth, check_audit and, with organisations, check_tenancy against it, and sync --check in CI.
  6. Decide where audit_log is backed up and for how long it is kept.

Next: Deploy and operate, Data and migrations, Limits.