Rephi.Authorization.Permission (Rephi v0.0.2)
View SourceSchema and validations for permissions in the authorization system.
Permissions represent granular access rights that can be assigned to roles or directly to users. Permissions support hierarchical organization where child permissions can inherit from parent permissions.
Fields
name
- Human-readable permission name (e.g., "View Users")slug
- Unique identifier using colon notation (e.g., "users:view")description
- Optional description of what the permission allowsparent_id
- Optional reference to parent permission for hierarchy
Permission Naming Convention
Permissions use colon notation to organize by domain:
users:view
- View user informationusers:create
- Create new usersroles:edit
- Edit role informationsystem:manage
- System administration
Associations
parent
- Parent permission in hierarchychildren
- Child permissions that inherit from this oneroles
- Roles that have this permission assignedusers
- Users who have this permission directly assigned
Examples
iex> changeset = Permission.changeset(%Permission{}, %{
...> name: "View Users",
...> slug: "users:view",
...> description: "Allows viewing user profiles and listings"
...> })
iex> changeset.valid?
true
Summary
Functions
Validates and casts permission attributes.
Functions
Validates and casts permission attributes.
Required Fields
name
- Must be presentslug
- Must be present and unique
Validations
slug
must contain only lowercase letters, numbers, colons, underscores, and hyphensslug
must be unique across all permissionsparent_id
must reference a valid permission if provided
Examples
iex> Permission.changeset(%Permission{}, %{
...> name: "Edit Users",
...> slug: "users:edit"
...> })
%Ecto.Changeset{valid?: true}
iex> Permission.changeset(%Permission{}, %{name: "", slug: ""})
%Ecto.Changeset{valid?: false}
iex> Permission.changeset(%Permission{}, %{
...> name: "Test",
...> slug: "Invalid Slug!"
...> })
%Ecto.Changeset{valid?: false}