Guardian.Plug.EnsureSession

This plug ensures that a valid JWT was provided and has been verified on the request.

If one is not found, the on_failure function is invoked with the Plug.Conn.t object and it’s params.

Example

plug Guardian.Plug.EnsureSession, on_failure: { SomeModule, :some_method } # look in the default location
plug Guardian.Plug.EnsureSession, on_failure: { SomeModule, :some_method }, key: :secret # look in the :secret location

The on_failure option must be passed. The corresponding function will be called with the Plug.Conn.t and it’s params.