# jwt

A public API's door: API keys and tokens for the program's own accounts,
the keys tokens are checked with at `/.well-known/jwks.json`, turned over
on a schedule. The keys and tokens are the back end's own (`auth.keyMake`,
`auth.token`); `requires scope("orders:read")` is what lets a bearer in.
The whole of it is [docs/jwt.md](../../docs/jwt.md).

```text
use "pkg:jwt/jwt.mote"

fn jwtScopes(user: string): string[] = ["orders:read"]

server route GET "/api/orders"(req) requires scope("orders:read")
  …
```

Settings, each optional: `JWT_ROTATE_DAYS` (30), `MOTE_TOKEN_ISSUER`.

| | |
|---|---|
| `GET /.well-known/jwks.json` | The public keys. |
| `jwtKeys`, `jwtKeyMake`, `jwtKeyRevoke` | `server fn`s for someone signed in, over their own keys. |
| `POST /api/token` | A short token for an API key. |
| `jwtMake`, `jwtCheck` | Tokens for and from other parties. |

Left out: revoking a token before it ends (make a key for that), opaque
tokens with introspection (RFC 7662), OAuth 2.0 authorization-server duties
(this is no identity provider for other sites). Tested by `tests/all.sh
real_identity_api`, over HTTP; nothing outside this repository has checked
its tokens.
