Skip to main content

almasix-permission

PyPI CI coverage python license

Roles and permissions for Almasix.

Install as almasix.permission:

pip install almasix-permission
# or from the framework extras:
pip install "almasix[permission]"
from almasix.permission import HasRoles, Permission, Role

Install (editable)

pip install -e ".[dev]"
smith vendor:publish --tag=permission-config
smith vendor:publish --tag=permission-migrations
# Enable teams / UUID *before* migrating if you need them
smith migrate

Mix HasRoles onto your user model:

from almasix.auth import AuthenticatableMixin
from almasix.orm import Model
from almasix.permission import HasRoles

class User(HasRoles, AuthenticatableMixin, Model):
    fillable = ("email", "name", "password")

Quick usage

from almasix.permission import Permission, Role

await Permission.create(name="edit articles")
await Role.create(name="writer")
role = await Role.find_by_name("writer")
await role.give_permission_to("edit articles")

await user.assign_role("writer")
await user.give_permission_to("delete articles")

assert await user.has_permission_to("edit articles")
assert user.can("edit articles")  # via Gate.before

API surface

Area Methods / tools
Permissions give_permission_to, revoke_permission_to, sync_permissions, has_permission_to, check_permission_to, has_direct_permission, get_all_permissions
Roles assign_role, remove_role, sync_roles, has_role, has_any_role, has_all_roles, has_exact_roles
Teams set_permissions_team_id / get_permissions_team_id
Prism @role, @hasrole, @haspermission, …
Middleware role:, permission:, role_or_permission: (optional ,guard)
Commands smith permission:create-role (--team-id), create-permission, show (style), assign-role, cache-reset, setup-teams

Features

  • Roles and permissions (direct or via roles), polymorphic assignment
  • Gate.before so user.can(…), @can, and can middleware work
  • Multi-guard namespacing
  • Teams (permission.teams + set_permissions_team_id)
  • Wildcard permissions (permission.enable_wildcard_permission)
  • Enum names (enum.Enum / StrEnum)
  • Cache + permission:cache-reset
  • Opt-in events (permission.events_enabled)
  • UUID/ULID via permission.key_type before migrate
  • Extending models through permission.models.*

Tests

make test
make test-cov   # fail_under=98 on almasix.permission

Discovery

[project.entry-points."almasix.providers"]
permission = "almasix.permission.provider:PermissionServiceProvider"

Or list the provider explicitly in config/app.py.

Metadata

Release files for almasix-permission 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for almasix-permission 0.1.0
File Size Uploaded Provenance Actions
almasix_permission-0.1.0.tar.gz 26.5 kB With provenance Details for almasix_permission-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for almasix-permission 0.1.0
File Interpreter ABI Platform Actions
almasix_permission-0.1.0-py3-none-any.whl Python 3 none any Details for almasix_permission-0.1.0-py3-none-any.whl

Total release size: 54.6 kB

Release files / almasix_permission-0.1.0.tar.gz

Download URL almasix_permission-0.1.0.tar.gz
Size 26.5 kB
Tags Source
SHA-256 checksum
How to use checksums
052e41795711b7f6d163c95ce77fa7bc0e43d6685c84564296efceace12836d2
BLAKE2b-256 checksum
How to use checksums
9765e4424e8e206c711a3fb2adac3b7679097f3a52b9cb69b3ebf48071d1ab86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release files / almasix_permission-0.1.0-py3-none-any.whl

Download URL almasix_permission-0.1.0-py3-none-any.whl
Size 28.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb7b9bc5f81514e98c8d2390b8b8a9b30ee097ee799e07178694ed1036a5f9a9
BLAKE2b-256 checksum
How to use checksums
75e27027df8ce7d97dea73b1f947f25f8f1b8cca36df4fa3e0408328408cc8a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Security for almasix-permission 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for almasix_permission-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page