IndieWeb.Auth.Code (IndieWeb v0.0.66) View Source

Handles authentication codes for the IndieAuth flow.

Link to this section Summary

Functions

Provides the age, in seconds, of a code.

Destroys all codes associated with the provided parameters.

Generates a code for IndieAuth based on the client_id, redirect_uri and any other extra parameters.

Generates a PKCE-compatible challenge string for the provided parameters.

Persists the provided challenge and method for the provided code.

Verifies a code with the provided fields.

Link to this section Functions

Specs

age(keyword()) :: non_neg_integer()

Provides the age, in seconds, of a code.

Link to this function

destroy(code, options \\ [])

View Source

Specs

destroy(binary(), keyword()) :: :ok

Destroys all codes associated with the provided parameters.

Specs

generate(keyword()) :: binary()

Generates a code for IndieAuth based on the client_id, redirect_uri and any other extra parameters.

Link to this function

generate_challenge(options \\ [])

View Source

Specs

generate_challenge(keyword()) :: {binary(), binary(), binary()}

Generates a PKCE-compatible challenge string for the provided parameters.

Link to this function

persist(code, client_id, redirect_uri, params \\ %{}, options \\ [])

View Source

Specs

persist(binary(), binary(), binary(), map(), keyword()) :: :ok

Stores a code for later verification.

Provided a code, a client's ID client_id, the URL that this should redirect to redirect_uri as well as any arguments used to craft this authorization request in params, store said code and references to for later verification.

Link to this function

persist_challenge(code, challenge, method, options \\ [])

View Source

Specs

persist_challenge(binary(), binary(), binary(), keyword()) ::
  :ok | {:error, any()}

Persists the provided challenge and method for the provided code.

Link to this function

verify(code, client_id, redirect_uri, options \\ [])

View Source

Specs

verify(binary(), binary(), binary(), keyword()) ::
  {:ok, map()} | {:error, any()}

Verifies a code with the provided fields.

Confirms that a code code was created for the provided client's ID client_id, the URL that this should redirect to redirect_uri as well as any arguments used to craft this authorization request in params.

Link to this function

verify_challenge(verifier, code, options \\ [])

View Source

Specs

verify_challenge(binary(), binary(), keyword()) ::
  {:ok, [{:code, binary()}]} | {:error, any()}