View Source Charon.AuthFlow (Charon v0.0.3-alpha)
An authentication flow that can be used to log in. A flow consists of stages, each of which has to be passed in order to log in. A stage consists of challenges, one of which has to be passed in order to pass the stage.
Link to this section Summary
Types
A set of auth flows.
An authentication flow that can be used to log in. A flow consists of stages, each of which has to be passed in order to log in. A stage consists of challenges, one of which has to be passed in order to pass the stage.
Functions
After completing a challenge, pass the result to this function. If the challenge is completed successfully and it is the final stage of an auth flow, a session is created and tokens are handed out. If the challenge is completed successfully but it is not the final stage of an auth flow, the next stage is returned. If the challenge fails, the error is returned.
Initialize a new auth flow. Creates a protosession and a token to complete its auth flow with.
Create a flow set from a list of t:Charon.AuthFlow.t()
.
Verify a protosession token, load its protosession and find the requested challenge.
Create a challenge map (challenges mapped to their names) from a flow set.
Link to this section Types
A set of auth flows.
@type t() :: %Charon.AuthFlow{name: String.t(), stages: [Charon.AuthFlow.Stage.t()]}
An authentication flow that can be used to log in. A flow consists of stages, each of which has to be passed in order to log in. A stage consists of challenges, one of which has to be passed in order to pass the stage.
Link to this section Functions
handle_challenge_result(result, flow_set, session, conn, config, opts \\ [])
View Source@spec handle_challenge_result( {:ok, Plug.Conn.t(), map() | nil} | {:error, String.t() | map()}, flow_set(), Charon.Models.Session.t(), Plug.Conn.t(), Charon.Config.t(), keyword() ) :: {:flow_complete, Plug.Conn.t(), map()} | {:challenge_complete, Plug.Conn.t(), Charon.AuthFlow.Stage.t()} | {:error, String.t() | map()}
After completing a challenge, pass the result to this function. If the challenge is completed successfully and it is the final stage of an auth flow, a session is created and tokens are handed out. If the challenge is completed successfully but it is not the final stage of an auth flow, the next stage is returned. If the challenge fails, the error is returned.
@spec init(map() | struct(), flow_set(), String.t(), String.t(), Charon.Config.t()) :: {:ok, String.t()} | {:error, String.t()}
Initialize a new auth flow. Creates a protosession and a token to complete its auth flow with.
Create a flow set from a list of t:Charon.AuthFlow.t()
.
@spec process_token(String.t(), flow_set(), String.t(), Charon.Config.t()) :: {:ok, Charon.AuthChallenge.t(), Charon.Models.Session.t()} | {:error, String.t()}
Verify a protosession token, load its protosession and find the requested challenge.
@spec to_challenge_map(flow_set()) :: %{ required(String.t()) => Charon.AuthChallenge.t() }
Create a challenge map (challenges mapped to their names) from a flow set.