Guardian v0.13.0 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 unauthenticated/2 function is invoked with the Plug.Conn.t object and its params.

Example

# Will call the unauthenticated/2 function on your handler
plug Guardian.Plug.EnsureAuthenticated, handler: SomeModule

# look in the :secret location.  You can also do simple claim checks:
plug Guardian.Plug.EnsureAuthenticated, handler: SomeModule, key: :secret

plug Guardian.Plug.EnsureAuthenticated, handler: SomeModule, typ: "access"

If the handler option is not passed, Guardian.Plug.ErrorHandler will provide the default behavior.