Skip to content

Tokens and Permissions

Outcome: a token that can read one bucket and demonstrably nothing more — proved by one success and two refusals, each with its own status code. Transcript: influxdb-lab/transcripts/t06-tokens.txt.

The one rule, stated early

This is the chapter criteria point 8 sends you to, so it goes first and plainly: an InfluxDB token is the permission. There is no user session behind it and no password prompt at the door. A program holding a token can do everything the token allows, from anywhere the server can be reached, for as long as the token lives. The setup's operator token allows everything — read and write every bucket, mint more tokens, delete the database's contents. Guard tokens the way you guard passwords, because in every way that matters they are stronger: they never expire unless you revoke them, and they are shown in full exactly once, at creation.

What the house already holds

influx auth ls
ID          Description     Token   User Name   Permissions
119144f7f652a000    admin's Token           admin       [read:/authorizations write:/authorizations read:/buckets write:/buckets …]
119146764192a000    weather read-only (lab)     admin       [read:orgs/bf6893ac12376786/buckets/4ed5a2165acd01fe]

Notice the empty Token column. auth ls lists what tokens exist, who they belong to, and what they may do — and will not print their values, at any verbosity. If a token's value is lost, the recovery is to revoke and re-mint, never to look it up. That is deliberate design, and it is why the value goes into your password manager in the same minute it is created.

Minting a small key

The lab's second token was made for one job — let a dashboard read the weather bucket — and it carries exactly one permission, named by bucket ID:

influx auth create --org example-org \
  --description 'weather read-only (lab)' \
  --read-bucket 4ed5a2165acd01fe

The create output prints the token once (the transcript redacts it; the lab's instance was disposable and destroyed). Permissions in this system are built from pairs like --read-bucket, --write-bucket, --read-org, --write-task — one flag per power. The discipline is to grant the job's powers and stop.

The three proofs

The lab then used the scoped token through the HTTP API (chapter 8 shows the mechanics). Reading its own bucket: 200, and the row comes back. Writing to that same bucket: 403 Forbidden, insufficient permissions for write — the token is known, and refused. Reading the other bucket, weather-recent: 404 Not Found, could not find bucket "weather-recent" — not a refusal but an absence. A token that cannot read a bucket cannot even learn that it exists. Those three codes are the whole security model in one glance: 401 for no valid token, 403 for a token, but not for this, 404 for a token, but that is not yours to see.

A second privacy consequence deserves naming, because it surprises people: measurements themselves can be personal. A temperature series reveals when a house wakes and sleeps; a power series reveals holidays. Scoped tokens are therefore not just tidiness — they are how you hand a graph to one program without handing it your household's rhythms. Store measurements as if they describe people, because often enough, they do.

House rules, collected

  • One token per program or job; never share the operator token with an application.
  • Read-only by default; write access is the exception that must argue for itself.
  • Values go into a password manager at creation; a token in a script file or a shell history is a token published.
  • Revoke (influx auth delete) the moment a job ends or a value might have escaped. Revocation is instant and total — the lab's transcripts are evidence it needs no ceremony.