Identity headers
Let the program behind a Web Service know which Device, and which person, opened it.
With Tell the program who is asking on, a Web Service passes each request to its program with headers that say who made it. The program can then sign people in without a password of its own, or keep its own accounts and use the headers to match them.
Turn it on in the Service's form (Services → the Service → Edit), or send "identity_headers": true in the
API. It exists for Web Services only.
The headers
| Header | Sent for | Example |
|---|---|---|
Tiltas-Device | every request | macbook |
Tiltas-Device-Id | every request | dev_3n7q |
Tiltas-Member-Id | a Personal device | mem_jonas |
Tiltas-Email | a Personal device | jonas@example.org |
Tiltas-Name | a Personal device, URL-encoded | Jonas%20%C5%BDukas |
A request from a Server carries only the two Device headers: a Server belongs to the Account, not to a person. Decode
Tiltas-Name before you show it; it is URL-encoded so names in any language survive the trip.
Match people by Tiltas-Member-Id, which never changes. An email address can change, and a Device can be renamed.
They cannot be forged
The hosting Device removes every Tiltas- header the visitor sent, whatever its spelling, also with underscores instead
of dashes, and then sets its own from what the Coordinator says about the visitor's Device address. A visitor cannot
claim to be someone else.
That guarantee holds only for requests that come through the Service. Keep the program listening on 127.0.0.1 and the
Service's target on localhost, so nothing else can reach it: see Keep the program on localhost.
Headers under the names used before the rename are removed too, so those cannot be forged either. A hosting Device that has not updated since the rename still sends the headers under the old names: the migration note lists them.
Read them
Each of these answers on port 3000 of the hosting Device, so the Service's target is localhost:3000. Without the
headers, the request did not come through Tiltas.
import { createServer } from "node:http"
createServer((req, res) => {
const device = req.headers["tiltas-device"]
const memberId = req.headers["tiltas-member-id"]
const email = req.headers["tiltas-email"]
const name = req.headers["tiltas-name"] ? decodeURIComponent(req.headers["tiltas-name"]) : undefined
res.setHeader("Content-Type", "text/plain; charset=utf-8")
if (!device) return res.writeHead(401).end("Open this through Tiltas.\n")
if (!memberId) return res.end(`Hello, Server ${device}.\n`)
res.end(`Hello, ${name} <${email}> on ${device}.\n`)
}).listen(3000, "127.0.0.1")Opened from the Personal device macbook of Jonas, each one answers:
Hello, Jonas Žukas <jonas@example.org> on macbook.The Node.js sample is an ES module: save it as server.mjs. The Python and Go samples use only the standard library.
The other headers
The program also gets X-Forwarded-For with the visitor's Device address, and X-Forwarded-Host and
X-Forwarded-Proto. See What a target can be.