Packages
guardian
1.2.1
2.4.0
2.3.2
2.3.1
2.3.0
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.2
2.1.1
2.0.0
1.2.1
1.2.0
retired
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-beta.1
1.0.0-beta.0
0.14.6
0.14.5
0.14.4
0.14.3
retired
0.14.2
0.14.1
0.14.0
0.13.0
0.12.0
0.11.1
0.10.1
0.10.0
0.9.1
0.9.0
0.8.1
0.8.0
0.7.4
0.7.2
0.7.1
0.7.0
0.6.3
0.6.2
0.6.1
0.6.0
0.5.2
0.5.0
0.4.1
0.4.0
0.3.1
0.3.0
0.2.0
0.1.1
0.1.0
Elixir Authentication framework
Current section
Files
Jump to
Current section
Files
lib/guardian/plug/error_handler.ex
if Code.ensure_loaded?(Plug) do
defmodule Guardian.Plug.ErrorHandler do
@moduledoc """
Optional Behaviour for creating error handlers for `Guardian.Plug.Pipeline`.
### Error handler
When using plugs, you'll need to specify an error handler module
The error_handler module requires an `auth_error` function that receives the conn,
the reason tuple and the options
```elixir
defmodule MyApp.AuthErrorHandler do
@behaviour Guardian.Plug.ErrorHandler
@impl Guardian.Plug.ErrorHandler
def auth_error(conn, {type, reason}, opts) do
...
end
end
```
By default, Guardian will emit types of:
```
* :unauthorized
* :invalid_token
* :already_authenticated
* :no_resource_found
```
"""
@callback auth_error(
conn :: Plug.Conn.t(),
{type :: atom, reason :: atom},
opts :: Guardian.options()
) :: Plug.Conn.t()
end
end