Karta. Accounts. Scope
(Karta v1.0.0)
Who is acting, and what they may do: the signed-in user and their role in
each organisation. Every page and action of the admin interface gets one
(current_scope) and asks can?/3 before it shows or changes anything.
Roles, per organisation (Karta.Accounts.Membership):
| Action | owner | admin | member | read-only |
|---|---|---|---|---|
:view | ✓ | ✓ | ✓ | ✓ |
:manage_messages | ✓ | ✓ | ✓ | |
:manage_credentials | ✓ | ✓ | ✓ | |
:manage_servers | ✓ | ✓ | ||
:manage_inbound | ✓ | ✓ | ||
:manage_webhooks | ✓ | ✓ | ||
:manage_domains | ✓ | ✓ | ||
:manage_members | ✓ | ✓ | ||
:manage_owners | ✓ | |||
:manage_organisation | ✓ |
:view covers the organisation, its servers, domains, credentials (never
their secrets), messages with their bodies, deliveries, received mail
with its deliveries, and webhooks with their deliveries (never their
secrets). :manage_inbound adds, changes and removes a server's routes
and endpoints (never showing their secrets again), and sends a received
message's failed or waiting delivery again. :manage_webhooks adds,
changes, tests and removes a server's webhooks, rotates their secrets and
sends their deliveries again.
:manage_members adds, removes and changes members below owner;
:manage_owners makes or removes owners. :manage_organisation renames
or deletes the organisation.
Instance administrators (admin users) may do everything in every
organisation, and they alone may create organisations
(can?(scope, :create_organisation)).
Summary
Functions
True for an instance administrator.
The actions a role allows.
True when the scope may take an action that belongs to no organisation.
True when the scope may take action in the organisation.
A scope for user and their memberships ([Membership]).
The user's role in the organisation (nil when not a member).
Types
@type action() ::
:view
| :manage_messages
| :manage_credentials
| :manage_servers
| :manage_inbound
| :manage_webhooks
| :manage_domains
| :manage_members
| :manage_owners
| :manage_organisation
@type role() :: :owner | :admin | :member | :read_only
@type t() :: %Karta.Accounts.Scope{ roles: %{required(binary()) => role()}, user: Karta.Accounts.User.t() | nil }
Functions
True for an instance administrator.
The actions a role allows.
True when the scope may take an action that belongs to no organisation.
True when the scope may take action in the organisation.
@spec new(Karta.Accounts.User.t(), [Karta.Accounts.Membership.t()]) :: t()
A scope for user and their memberships ([Membership]).
The user's role in the organisation (nil when not a member).