View Source Mobilizon.Web.Auth.Guardian (Mobilizon v5.0.0-beta.1)

Handles the JWT tokens encoding and decoding

Summary

Functions

Callback implementation for Guardian.build_claims/3.

Fetches the configuration for this module.

Returns a resolved value of the configuration found at a key.

Decodes and verifies a token using the configuration on the implementation module.

The default type of token for this module.

Exchanges a token of one type for another.

Provides the content of the token but without verification of either the claims or the signature.

Fetch the resource and claims directly from a token.

Revoke a token.

If Guardian.Plug.SlidingCookie is used, this callback will be invoked to return the new claims, or an error (which will mean the cookie will not be refreshed).

Functions

Link to this function

after_encode_and_sign(resource, claims, token, arg4)

View Source
@spec after_encode_and_sign(any(), any(), any(), any()) :: {:ok, String.t()}

Callback implementation for Guardian.after_encode_and_sign/4.

Link to this function

after_sign_in(conn, r, t, c, o)

View Source

Callback implementation for Guardian.after_sign_in/5.

Link to this function

before_sign_out(conn, location, opts)

View Source

Callback implementation for Guardian.before_sign_out/3.

Callback implementation for Guardian.build_claims/3.

@spec config() :: Keyword.t()

Fetches the configuration for this module.

Link to this function

config(key, default \\ nil)

View Source
@spec config(atom() | String.t(), any()) :: any()

Returns a resolved value of the configuration found at a key.

See Guardian.Config.resolve_value/1.

Link to this function

decode_and_verify(token, claims_to_check \\ %{}, opts \\ [])

View Source
@spec decode_and_verify(
  Guardian.Token.token(),
  Guardian.Token.claims(),
  Guardian.options()
) ::
  {:ok, Guardian.Token.claims()} | {:error, any()}

Decodes and verifies a token using the configuration on the implementation module.

See Guardian.decode_and_verify/4.

@spec default_token_type() :: String.t()

The default type of token for this module.

Link to this function

encode_and_sign(resource, claims \\ %{}, opts \\ [])

View Source
@spec encode_and_sign(any(), Guardian.Token.claims(), Guardian.options()) ::
  {:ok, Guardian.Token.token(), Guardian.Token.claims()} | {:error, any()}

Encodes the claims.

See Guardian.encode_and_sign/4 for more information.

Link to this function

exchange(token, from_type, to_type, opts \\ [])

View Source
@spec exchange(
  token :: Guardian.Token.token(),
  from_type :: String.t() | [String.t(), ...],
  to_type :: String.t(),
  options :: Guardian.options()
) ::
  {:ok, {Guardian.Token.token(), Guardian.Token.claims()},
   {Guardian.Token.token(), Guardian.Token.claims()}}
  | {:error, any()}

Exchanges a token of one type for another.

See Guardian.exchange for more information.

Link to this function

on_exchange(old_stuff, new_stuff, options)

View Source
@spec on_exchange(any(), any(), any()) ::
  {:ok, {String.t(), map()}, {String.t(), map()}} | {:error, any()}

Callback implementation for Guardian.on_exchange/3.

Link to this function

on_refresh(old_stuff, new_stuff, options)

View Source
@spec on_refresh({any(), any()}, {any(), any()}, any()) ::
  {:ok, {String.t(), map()}, {String.t(), map()}} | {:error, any()}

Callback implementation for Guardian.on_refresh/3.

Link to this function

on_revoke(claims, token, options)

View Source
@spec on_revoke(any(), any(), any()) ::
  {:ok, map()} | {:error, :could_not_revoke_token}

Callback implementation for Guardian.on_revoke/3.

Link to this function

on_verify(claims, token, options)

View Source
@spec on_verify(any(), any(), any()) :: {:ok, map()} | {:error, :token_not_found}

Callback implementation for Guardian.on_verify/3.

@spec peek(String.t()) :: map()

Provides the content of the token but without verification of either the claims or the signature.

Claims will be present at the :claims key.

See Guardian.peek/2 for more information.

Link to this function

refresh(old_token, opts \\ [])

View Source

Refresh a token.

See Guardian.refresh for more information.

Link to this function

resource_from_claims(arg1)

View Source
@spec resource_from_claims(any()) ::
  {:error, :invalid_id | :no_result | :no_claims}
  | {:ok, Mobilizon.Users.User.t()}

Callback implementation for Guardian.resource_from_claims/1.

Link to this function

resource_from_token(token, claims_to_check \\ %{}, opts \\ [])

View Source
@spec resource_from_token(
  token :: Guardian.Token.token(),
  claims_to_check :: Guardian.Token.claims() | nil,
  opts :: Guardian.options()
) :: {:ok, Guardian.Token.resource(), Guardian.Token.claims()} | {:error, any()}

Fetch the resource and claims directly from a token.

See Guardian.resource_from_token for more information.

Link to this function

revoke(token, opts \\ [])

View Source
@spec revoke(Guardian.Token.token(), Guardian.options()) ::
  {:ok, Guardian.Token.claims()} | {:error, any()}

Revoke a token.

See Guardian.revoke for more information.

Link to this function

sliding_cookie(current_claims, current_resource, opts \\ [])

View Source
@spec sliding_cookie(
  current_claims :: Guardian.Token.claims(),
  current_resource :: Guardian.Token.resource(),
  options :: Guardian.options()
) :: {:ok, new_claims :: Guardian.Token.claims()} | {:error, any()}

If Guardian.Plug.SlidingCookie is used, this callback will be invoked to return the new claims, or an error (which will mean the cookie will not be refreshed).

Link to this function

subject_for_token(arg1, arg2)

View Source
@spec subject_for_token(any(), any()) ::
  {:ok, String.t()} | {:error, :unknown_resource}

Callback implementation for Guardian.subject_for_token/2.

Link to this function

verify_claims(claims, options)

View Source

Callback implementation for Guardian.verify_claims/2.