Skip to main content

File management solution for Masonite

Project description

Masonite Permission

GitHub Workflow Status PyPI issues Python Version GitHub release (latest by date including pre-releases) License star downloads Code style: black

Introduction

Associate users with roles and permissions

Features

Installation

pip install masonite-permission

Configuration

Add PermissionProvider to your project in config/providers.py:

# config/providers.py
# ...
from masonite_permission import PermissionProvider

# ...
PROVIDERS = [
    # ...
    # Third Party Providers
    PermissionProvider,
    # ...
]

Then you can publish the package resources (if needed) by doing:

python craft package:publish masonite-permission

Usage

""" Permission Syncing """
permissions = Permission.all()
role.sync_permissions(permissions) # sync permissions to role
role.sync_permissions([]) # remove all permissions from role

""" Attach/Detatch Permission """
permission = Permission.first()
role.attach_permission(permission) # add permission to role, ignores if permission already exists
role.detach_permission(permission) # remove permission from role, ignores if permission doesn't exist

""" Role Syncing """
roles = Role.all()
permission.sync_roles(roles) # sync roles to role
permissioin.sync_roles([]) # remove all roles from role

""" Attach/Detatch Role """
role = Role.first()
permission.attach_role(role) # add role to permission, ignores if role already exists
permission.detach_role(role) # remove role from permission, ignores if role doesn't exist

Contributing

Please read the Contributing Documentation here.

Maintainers

License

Masonite Permission is open-sourced software licensed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

masonite-permission-0.1.2.tar.gz (77.8 kB view hashes)

Uploaded Source

Built Distribution

masonite_permission-0.1.2-py3-none-any.whl (8.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page