Guardian.Plug.EnsureAuthenticated
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.EnsureAuthenticated, on_failure: { SomeModule, :some_method } # look in the default location
plug Guardian.Plug.EnsureAuthenticated, on_failure: { SomeModule, :some_method }, key: :secret # look in the :secret location
You can also do simple claim checks:
plug Guardian.Plug.EnsureAuthenticated, on_failure: { SomeModule, :some_method }, aud: "token"
The on_failure option must be passed. The corresponding function will be called with the Plug.Conn.t and it’s params.