Phauxth v0.13.0-rc.0 Phauxth.Authenticate.Base View Source
Base module for authentication.
This is used by Phauxth.Authenticate and Phauxth.Remember. It can also be used to produce a custom authentication module, as outlined below.
Custom authentication modules
One example of a custom authentication module is provided by the Phauxth.Remember module, which uses this base module to provide the ‘remember me’ functionality.
Graphql authentication
The following module is another example of how this Base module can be extended, this time to provide authentication for absinthe-elixir:
defmodule AbsintheAuthenticate do
use Phauxth.Authenticate.Base
import Plug.Conn
def set_user(user, conn) do
put_private(conn, :absinthe, %{token: %{current_user: user}})
end
end
And in the router.ex
file, call this plug in the pipeline you
want to authenticate (setting the token key source to the app’s endpoint).
plug :api do
plug AbsintheAuthenticate, token: MyApp.Web.Endpoint
end
Link to this section Summary
Functions
Check the headers for an authorization token
Check the conn to see if the user is registered in the current session
Check the authorization token
Log the result of the authentication and return the user struct or nil
Link to this section Functions
Check the headers for an authorization token.
This function also calls the database to get user information.
Check the conn to see if the user is registered in the current session.
This function also calls the database to get user information.
Check the authorization token.
This function also calls the database to get user information.
Log the result of the authentication and return the user struct or nil.