Rivet.Auth.Graphql (rivet_ident v3.5.0)

View Source

Helpers for Graphql resolvers.

Summary

Functions

This wraps check_authz with logging and creates normal error output for Absinthe to handle.

Accept authorization from a user. Punt to authz_action(), but log graphql bits.

check_authz/2 attempts to verify %Auth.Assertion{} against the specified user, and if the assertion includes a domain reference, it will attempt to walk up the reference tree (if a parent_id exists) and try checking auth again.

Handles extracting the current user from the Absinthe context, and then will either call func and pass in the current user or return an error if there is no user in the context

Types

az_assertion()

@type az_assertion() :: Rivet.Auth.Assertion.t()

az_log()

@type az_log() :: String.t() | nil

az_user()

@type az_user() :: Rivet.Ident.User.t() | map()

Functions

action(a, opts \\ [])

@spec action(
  atom(),
  keyword()
) :: Rivet.Auth.Assertion.t()

authz(meta, assertion, log \\ nil, kwlog \\ [])

This wraps check_authz with logging and creates normal error output for Absinthe to handle.

with {:ok, authed} <- authz(context, %Rivet.Auth.Assertion{}, "doTheThing") do
  handle success
end

authz_user(context, assertion \\ %Auth.Assertion{action: :system_admin}, method \\ nil, kwlog \\ [])

Accept authorization from a user. Punt to authz_action(), but log graphql bits.

check_authz(user, assertion)

check_authz/2 attempts to verify %Auth.Assertion{} against the specified user, and if the assertion includes a domain reference, it will attempt to walk up the reference tree (if a parent_id exists) and try checking auth again.

current_user(arg1)

Handles extracting the current user from the Absinthe context, and then will either call func and pass in the current user or return an error if there is no user in the context

current_user(arg1, method)