PgRest.JWT.HS256 (PgRest v0.2.0)

Copy Markdown View Source

HS256 bearer-token verification (PgRest.JWT.Verifier), with PostgREST's errors and claim rules: exp, nbf and iat are checked with :leeway seconds of clock skew, aud against :audience when one is set.

Options

  • :secret (required) - at least 32 bytes: a binary, {:system, "ENV_VAR"}, {module, function, args} or a zero-arity function. A source other than a binary is resolved on every verification, so the secret need not exist when the router compiles. A literal binary under 32 bytes raises at init; a resolved secret that is missing or too short is a 500, logged without its value.
  • :audience - the expected aud (default nil: any aud that is a string or an array of strings)
  • :leeway - seconds of clock skew (default 30, PostgREST's)

Differences from PostgREST

  • A missing or short secret is a generic 500 PGRSTX00; PostgREST answers PGRST300 Server lacks JWT secret. Only a server-side message is logged, never the value.