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, handler: SomeModule # Will call the unauthenticated function on your handler
plug Guardian.Plug.EnsureAuthenticated, handler: SomeModule, key: :secret # look in the :secret location. You can also do simple claim checks:
plug Guardian.Plug.EnsureAuthenticated, handler: SomeModule, aud: "token"
The handler option may be passed. By default Guardian.Plug.ErrorHandler is used and the :unauthenticated
function will be called.
The handler will be called on failure.
The :unauthenticated
function will be called when a failure is detected.