Helper libraries
Sign-in itself is plain OpenID Connect, so use any certified library for it (the quickstarts use Auth.js, openid-client, go-oidc and Authlib). You need more only when your code has to check Tessera...
On this page
Planned. Tessera will publish small Go and TypeScript helper libraries for the checks that APIs and backends often need. They are not published yet, and there is nothing to install. Everything they would do is standard OAuth 2.0 and OpenID Connect, and this page shows how to do each job today with libraries you already use.
Sign-in itself is plain OpenID Connect, so use any certified library for it (the quickstarts use Auth.js, openid-client, go-oidc and Authlib). You need more only when your code has to check Tessera tokens or events for itself.
What to use for each job
| Job | The plain way |
|---|---|
| Validate an access token in your API | Check the signature against <issuer>/jwks, then typ, iss, aud and exp: below |
| Validate an ID token | Your OIDC library does it (openid-client, go-oidc, Authlib, Auth.js) |
| Verify back-channel logout tokens | Logout lists the checks |
| Verify webhook signatures | HMAC-SHA256 over timestamp.body, in TypeScript and Python on Webhooks |
| Check roles and permissions | Read the roles and permissions claims after validating: claims |
| Protect an MCP server | The metadata document and the 401 challenge: MCP quickstart |
| Follow the revocation feed | GET /revocations, a signed document: endpoints |
| Introspect or revoke a token | POST /introspect and POST /revoke: endpoints |
| Get and renew a token for an agent or job | One POST /token: get and refresh tokens in code |
| Device flow, token exchange | Plain form posts: get and refresh tokens in code |
| Call the admin API | A bearer token with audience tessera-admin: calling the admin API |
Validate an access token in your API
An access token is a signed JWT. Your API checks, on every request:
- the signature, against the realm's keys at
<issuer>/jwks(EdDSAorRS256, chosen by the header'skid; cache the key set and refetch on an unknownkid); - the header
typisat+jwt, so an ID token or logout token is never taken for an access token; issequals your realm's issuer exactly (for examplehttps://login.kurthlabs.com/realms/acme);audcontains your API's identifier. For a token a plain sign-in app got for itself (noresource), the audience is the app'sclient_id;exphas not passed, with a little clock leeway.
TypeScript, with jose:
import { createRemoteJWKSet, jwtVerify } from "jose";
const issuer = "https://login.kurthlabs.com/realms/acme";
const jwks = createRemoteJWKSet(new URL(`${issuer}/jwks`));
export async function validate(token: string) {
const { payload } = await jwtVerify(token, jwks, {
issuer,
audience: "https://api.example.com",
typ: "at+jwt",
algorithms: ["EdDSA", "RS256"],
});
return payload; // throws on any failure: answer 401
}Go, with go-oidc (its verifier checks the signature, iss and exp; the audience and typ are two lines of your own):
const (
issuer = "https://login.kurthlabs.com/realms/acme"
audience = "https://api.example.com"
)
var verifier = oidc.NewVerifier(issuer, oidc.NewRemoteKeySet(context.Background(), issuer+"/jwks"), &oidc.Config{
SkipClientIDCheck: true, // the audience is checked below
SupportedSigningAlgs: []string{"EdDSA", "RS256"},
})
func validate(ctx context.Context, raw string) (map[string]any, error) {
header, _, _ := strings.Cut(raw, ".")
decoded, err := base64.RawURLEncoding.DecodeString(header)
if err != nil {
return nil, err
}
var h struct{ Typ string }
if json.Unmarshal(decoded, &h) != nil || !strings.EqualFold(h.Typ, "at+jwt") {
return nil, errors.New("not an access token")
}
token, err := verifier.Verify(ctx, raw)
if err != nil {
return nil, err
}
if !slices.Contains(token.Audience, audience) {
return nil, errors.New("token is for another API")
}
var claims map[string]any
return claims, token.Claims(&claims)
}Return 401 with a WWW-Authenticate: Bearer header when validation fails. For an MCP server the header also points at your protected-resource metadata: see the MCP quickstart. These checks happen offline, so a revoked token is noticed only when it expires. To notice sooner, call POST /introspect for sensitive actions or follow the revocation feed.
Webhooks and logout
Webhook signatures are an HMAC you can check with the standard library in any language: Webhooks has TypeScript and Python code. Back-channel logout tokens are JWTs signed with the same keys as above: Logout lists what to check.