ProcaWeb.Plugs.JwtAuthPlug (proca v3.4.1)

A plug that reads JWT from Authorization header and authenticates the user.

options:

  • query_param - specify if you want to fetch JWT from a query param
  • enable_session - set user also in phoenix session
  • email_path - list of keys to get email from in JWT (default ["email"])
  • email_verified_path = list of keys to get email verified info (default user_metadata.email_verified)
  • external_id_path - list of keys to get external_id from JWT (default ["sub"])

Link to this section Summary

Functions

Callback implementation for Plug.call/2.

extract field from nested map, using a path to fetch key

Callback implementation for Plug.init/1.

Return the current user context based on the authorization header

Link to this section Functions

Link to this function

call(conn, opts)

Callback implementation for Plug.call/2.

Link to this function

check_email_verified(claims, path)

Link to this function

check_expiry(claims)

Link to this function

extract_field(claims, paths)

extract field from nested map, using a path to fetch key:

eg. session.identity.emails.[].email use [] to access an array (fetching first result)

Pass a list of paths to try all of them.

Link to this function

get_key_jwks(algo, key_id)

Link to this function

get_key_secret(algo)

Link to this function

get_or_create_user(conn, email, external_id)

Callback implementation for Plug.init/1.

Link to this function

jwt_auth(conn, opts)

Return the current user context based on the authorization header