View Source Rivet.Auth.Graphql (rivet_ident v3.0.2)

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

@type az_assertion() :: Rivet.Auth.Assertion.t()
@type az_log() :: String.t() | nil
@type az_user() :: Rivet.Ident.User.t() | map()

Functions

@spec action(
  atom(),
  keyword()
) :: Rivet.Auth.Assertion.t()
Link to this function

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

View Source

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
Link to this function

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

View Source

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

Link to this function

check_authz(user, assertion)

View Source

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

Link to this function

current_user(arg1, method)

View Source