Static auth
- Package
@mercury-fw/auth-static- Role
- Auth provider
- Version
- 0.2.2
bun add @mercury-fw/auth-static| Variable | What it is |
|---|---|
AUTH_STATIC_TOKENS | Required. JSON from bearer token to user, test tokens only: {"<token>": {"id": "alice", "displayName": "Alice"}} |
A fixed map from token to user, for trying the HTTP channel on your machine and for end-to-end tests: two tokens are two users, and you can check that one doesn’t see the other’s things. For real people use OpenID Connect auth.
import { staticAuth } from "@mercury-fw/auth-static";
auth: staticAuth,AUTH_STATIC_TOKENS={"alice-token": {"id": "alice", "displayName": "Alice"}, "bob-token": {"id": "bob"}}A caller sending Authorization: Bearer alice-token is static:alice; anything else is refused. The tokens are
secrets even here, so they live in .env only. A missing or malformed list stops the provider, and the HTTP channel
doesn’t start.