Skip to main content

Authentication

Tainha supports three authentication modes:

  1. Local JWT (HS256) — validate tokens with a shared secret
  2. JWKS (RS256/ES256) — validate tokens with public keys from a JWKS endpoint
  3. Auth Delegation — delegate validation to your own auth service

All modes protect routes marked as non-public and forward user claims as X- headers to your backend services.

Quick Comparison

Local JWTJWKSAuth Delegation
SetupSecret in configJWKS URL in configRunning auth service
AlgorithmsHS256RS256, ES256, etc.Any
PerformanceFastestFast (keys cached)Extra hop per request
ProvidersCustomAuth0, Keycloak, Firebase, CognitoAny
Use casePrototyping, simple appsStandard identity providersFull custom auth

Priority

If multiple options are configured:

authService > jwksUrl > secret

Public Routes

Mark routes as public: true to skip authentication:

routes:
- method: GET
route: /products
service: localhost:3000
path: /products
public: true

- method: GET
route: /orders
service: localhost:3000
path: /orders
# requires auth (default)

Claim Forwarding

In all modes, string claims are forwarded to your backend as X- headers:

JWT ClaimForwarded Header
usernameX-Username
roleX-Role
subX-Sub
emailX-Email

Your backend reads these headers to identify the user — no need to parse the token again.