PgRest.JWT.Verifier behaviour (PgRest v0.2.0)

Copy Markdown View Source

Verifies the bearer token of an RLS-mode request (PgRest.Plug's rls: [jwt: {module, opts}]).

verify/2 returns the token's claims, or the PgRest.Error to answer with (PostgREST's 401 PGRST301/PGRST303, built with PgRest.Error.invalid_token/3). init/1, when exported, validates opts once, when the plug is initialized, and returns what verify/2 receives. PgRest.JWT.HS256 is the built-in verifier.

Summary

Callbacks

init(opts)

(optional)
@callback init(opts :: keyword()) :: keyword()

verify(token, opts)

@callback verify(token :: String.t(), opts :: keyword()) ::
  {:ok, map()} | {:error, PgRest.Error.t()}