Authentication
Two ways in, neither a secret. A workload presents its platform's identity, or signs with a private key; Athanor holds nothing that can mint a token.
The API is OAuth2. A workload trades a credential for a short-lived access token at the auth service, then sends the token as a bearer to the API. What the credential is, is the part that matters.
There are no client secrets
Athanor does not issue client secrets. A client authenticates with the identity its platform already gives it, or with a private key whose public half it registered. Nothing that can obtain a token is stored on Athanor's side, and nothing long-lived is copied anywhere.
Where it runs: workload federation
The platform your code runs on already signs a short-lived token naming your workload: Vercel does for a function, GitHub for an Actions job, a Kubernetes cluster for a service account, your own identity provider for a machine. A trust policy on the client says which issuer and which claims to accept. The SDK presents that token to the token endpoint with the token-exchange grant (RFC 8693); the auth service verifies it against the issuer's own published keys and the policy, and issues an Athanor token with the client's scopes.
Nothing is generated, stored or rotated. Revoking the client ends access.
Set it up [step]
Settings → API → Clients → New client, choose Where it runs, pick the provider. For GitHub Actions, the repository and optionally a branch, tag or environment. For Vercel, the team and project and the environment. For any other OIDC issuer, the issuer URL, the audience it puts in the token, and the claims that identify the workload.
The policy requires an aud rule, so a token minted for another service never fits. The issuer must be an https URL whose host resolves to public addresses only.
In your code [step]
import { createClient, FederatedAuth, Vercel } from "@athanor-trade/sdk/promises";
const athanor = createClient({
environment: "live",
auth: FederatedAuth.layer({
clientId,
subjectToken: () => Vercel.subjectToken(),
scopes,
}),
});Vercel places the token in VERCEL_OIDC_TOKEN; vercel env pull writes it for local development. GitHub hands the runner's endpoint to the job; without an audience the token carries GitHub's default, https://github.com/<owner>, which is what the GitHub trust policy accepts.
The exchange, if you are not on the SDK
POST /api/oauth2/token
Content-Type: application/x-www-form-urlencoded
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
&client_id=<client id>
&subject_token=<the platform's token>
&subject_token_type=urn:ietf:params:oauth:token-type:jwt
&scope=dealer:orders:read dealer:orders:write
&resource=https://app.athanor.tradeA refusal is invalid_grant with the verifier's words: unknown-issuer, invalid-token, claims-mismatch naming the claim that failed. A client not registered for the exchange, or without a policy, is invalid_client.
A private key
For a system with no platform identity to present: a server in your own data center, say. Generate a key pair; register the public half as a JWKS on the client; keep the private half with the system. Every token request carries a fresh assertion signed with it, two minutes long, single use.
Set it up [step]
npx athanor-keygen > athanor-key.json # the PEM to keep and the JWKS to registerSettings → API → Clients → New client, choose A private key, paste the jwks. Rotate by minting a client with the new key and revoking the old one.
In your code [step]
import { createClient, PrivateKeyAuth } from "@athanor-trade/sdk/promises";
const athanor = createClient({
environment: "live",
auth: PrivateKeyAuth.layer({
clientId,
privateKey: { pem: process.env.ATHANOR_PRIVATE_KEY, algorithm: "ES256" },
scopes,
}),
});The grant, if you are not on the SDK
grant_type=client_credentials with client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer and a client_assertion whose issuer and subject are the client id, audience the token endpoint URL, exp within five minutes, and a jti used once. Algorithms: RS256/384/512, PS256/384/512, ES256/384/512, EdDSA.
The token
A JWT, an hour long, with aud the API host named by resource, azp the client id, scope the scopes granted, and organization_id the organization the client is bound to. Send it as Authorization: Bearer …. The SDK holds a token until shortly before it expires and shares one mint across concurrent callers.
Revoke a client from Settings and no token is issued to it again; one already out expires within the hour.