CommandedAggregateless. AuthSubject
(commanded_aggregateless v1.0.0)
Copy Markdown
Represents an actor that is attempting to execute a command or a query
Summary
Types
Map representation of an AuthSubject
The unique identifier of the entity that was cast to an AuthSubject
A permission that can be granted to an AuthSubject
List of permissions that have been granted to the auth subject
The original entity that was cast to an AuthSubject
Functions
Returns an AuthSubject that represents an anonymous user
Is the given value convertible to an AuthSubject?
Check if the AuthSubject satisfies the given permission set
Creates a new AuthSubject from the given data.
Creates a new AuthSubject from the given data.
Compares two datum to see if they convert to the same AuthSubject
Returns the "system user" to be used by internal processes that are ot triggered by a specific user.
Returns the list of all valid permissions that have been defined.
Types
@type as_map() :: %{source: source(), id: id(), permissions: permissions()}
Map representation of an AuthSubject
@type id() :: binary()
The unique identifier of the entity that was cast to an AuthSubject
@type permission() :: String.t()
A permission that can be granted to an AuthSubject
@type permissions() :: [permission() | permissions()]
List of permissions that have been granted to the auth subject
@type source() :: String.t()
The original entity that was cast to an AuthSubject
@type t() :: %CommandedAggregateless.AuthSubject{ id: id(), permissions: permissions(), source: source() }
Functions
@spec anonymous_user() :: t()
Returns an AuthSubject that represents an anonymous user
Is the given value convertible to an AuthSubject?
See CommandedAggregateless.AuthSubject.Conversion.convert/1.
@spec has_permission?(any(), atom() | permission() | [permission()]) :: boolean()
Check if the AuthSubject satisfies the given permission set
A permission set can consist of one or more permissions with the following formats:
"permission_a"- the AuthSubject must have permission_a["permission_a", "permission_b"]- the AuthSubject must have either permission_a or permission_b[["permission_a", "permission_b"]]- the AuthSubject must have both permission_a and permission_b[["permission_a", "permission_b"], "permission_c"]- the AuthSubject must have either permission_c or both permission_a and permission_b
@spec new(source :: CommandedAggregateless.AuthSubject.Conversion.t()) :: {:ok, t()} | {:error, {:invalid_auth_subject, keyword(keyword(String.t()))}}
Creates a new AuthSubject from the given data.
Returns {:ok, auth_subject} if the data is valid, otherwise {:error, message}.
@spec new!(CommandedAggregateless.AuthSubject.Conversion.t()) :: t()
Creates a new AuthSubject from the given data.
Raises ArgumentError if the data is invalid.
@spec same?( CommandedAggregateless.AuthSubject.Conversion.t(), CommandedAggregateless.AuthSubject.Conversion.t() ) :: boolean()
Compares two datum to see if they convert to the same AuthSubject
@spec system_user() :: t()
Returns the "system user" to be used by internal processes that are ot triggered by a specific user.
@spec valid_permissions() :: [String.t()]
Returns the list of all valid permissions that have been defined.