PermitEx.Scope (permit_ex v0.1.0)

Copy Markdown View Source

Authorization scope loaded from PermitEx role assignments.

Use this struct directly or merge its roles and permissions into your application's own Phoenix scope.

Summary

Functions

Builds a %PermitEx.Scope{} for the user and optional context.

Merges PermitEx authorization data into an existing map or struct.

Types

t()

@type t() :: %PermitEx.Scope{
  assigns: map(),
  context_id: Ecto.UUID.t() | nil,
  permissions: MapSet.t(String.t()),
  roles: [PermitEx.Role.t()],
  user_id: Ecto.UUID.t() | nil
}

Functions

for_user(user, context \\ nil, opts \\ [])

Builds a %PermitEx.Scope{} for the user and optional context.

Accepts ids, structs with an :id field, or maps with an "id" key.

put_permission_data(scope, user, context \\ nil, opts \\ [])

Merges PermitEx authorization data into an existing map or struct.