All Projects β†’ akiyamaSM β†’ Maravel Permissions

akiyamaSM / Maravel Permissions

Because in the Maravelous univer every user deserves super power

Projects that are alternatives of or similar to Maravel Permissions

Vue Gates
πŸ”’ A Vue.js & Nuxt.js plugin that allows you to use roles and permissions in your components or DOM elements, also compatible as middleware and methods.
Stars: ✭ 184 (+32.37%)
Mutual labels:  laravel, permissions, roles
Brandenburg
Laravel Authentication Package
Stars: ✭ 79 (-43.17%)
Mutual labels:  laravel, permissions, roles
Shinobi
πŸ‘Ί Simple and light-weight role-based permissions system for Laravel's built in Auth system.
Stars: ✭ 349 (+151.08%)
Mutual labels:  laravel, permissions, roles
Bouncer
Eloquent roles and abilities.
Stars: ✭ 2,763 (+1887.77%)
Mutual labels:  laravel, permissions, roles
Sentinel
A framework agnostic authentication & authorization system.
Stars: ✭ 1,354 (+874.1%)
Mutual labels:  laravel, permissions, roles
Laravel Governor
Manage authorization with granular role-based permissions in your Laravel Apps.
Stars: ✭ 131 (-5.76%)
Mutual labels:  laravel, permissions, roles
Laravel Auth
A powerful authentication, authorization and verification package built on top of Laravel. It provides developers with Role Based Access Control, Two-Factor Authentication, Social Authentication, and much more, compatible Laravel’s standard API and fully featured out of the box.
Stars: ✭ 128 (-7.91%)
Mutual labels:  laravel, permissions, roles
Laratrust
Handle roles and permissions in your Laravel application
Stars: ✭ 1,799 (+1194.24%)
Mutual labels:  laravel, permissions, roles
laravel-acl
Laravel ACL is a simple role, permission ACL for Laravel Framework.
Stars: ✭ 78 (-43.88%)
Mutual labels:  permissions, roles
laravel-inforce
A toolset to kickstart your application on top of Laravel Livewire, Laravel Jetstream and Spatie Permissions. LLoadout inforce is created using the TALL stack.
Stars: ✭ 12 (-91.37%)
Mutual labels:  permissions, roles
Policyserver.local
Sample OSS version of PolicyServer
Stars: ✭ 444 (+219.42%)
Mutual labels:  permissions, roles
Laravel Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.
Stars: ✭ 136 (-2.16%)
Mutual labels:  laravel, permissions
permissionary
Tiny and framework-agnostic role-based permission management using composition over inheritance
Stars: ✭ 19 (-86.33%)
Mutual labels:  permissions, roles
Django Role Permissions
A django app for role based permissions.
Stars: ✭ 465 (+234.53%)
Mutual labels:  permissions, roles
Ngx Permissions
Permission and roles based access control for your angular(angular 2,4,5,6,7,9+) applications(AOT, lazy modules compatible
Stars: ✭ 749 (+438.85%)
Mutual labels:  permissions, roles
Laravel Nova Permission
A Laravel Nova tool for the Spatie Permission package
Stars: ✭ 59 (-57.55%)
Mutual labels:  laravel, permissions
django-improved-permissions
Django application made to make django's default permission system more robust.
Stars: ✭ 14 (-89.93%)
Mutual labels:  permissions, roles
HeimGuard
πŸ›‘ A simple library that allows you to easily manage permissions in your .NET projects.
Stars: ✭ 77 (-44.6%)
Mutual labels:  permissions, roles
spree admin roles and access
Admin Roles And Access for Spree
Stars: ✭ 45 (-67.63%)
Mutual labels:  permissions, roles
ngx-security
Security directives for your Angular application to show/hide elements based on a user roles / permissions.
Stars: ✭ 18 (-87.05%)
Mutual labels:  permissions, roles

Grant Users the superpower of Marvel characters

inani-user2

Download

composer require inani/maravel-permissions

Installation

Then include the service provider inside config/app.php. (You can skipp it if it's in Laravel 5.5 or higher)

'providers' => [
    ...
    Inani\Maravel\Providers\MaravelServiceProvider::class,
    ...
];

Publish resources, and migrate

php artisan vendor:publish

PS : You can edit 2020_05_27_221346_add_role_id_to_users migration to link it with the correct user table

Edit the config/maravels.php with the correct values

<?php

return [
    // Define the list of actions to be checked against
    'actions' => [
        'add', 'delete', 'create', 'search', 'update'
    ],

    // define the class path for the entities
    'entities' => [
        \App\Models\User::class,
    ],
];

And then migrate

php artisan migrate

Setup a Model

To setup the user model, all you have to do is add (and import) the IsMarvel trait.

use Inani\Maravel\HasRole;

class User extends Model
{
    use HasRole;
    ...
}

Usage

All roles are role and permissions are powers

Because every user deserves to be a hero, The Maravel API is based on the Marvel Jargon, and here are how it can be used

// Having a user
$user = User::first();

// Create a new role, description is not mandotary
$userManager = RoleBuilder::create('User Manager', 'The role to manage users')
                ->havingPower([
                   'name' => 'can_update',
                   'description' => 'The abilitiy to update a user',
                   'action' => 'update',
                   'entity' => \App\Models\User::class,
               ]);

// we can grant a power to it
$userManager = RoleBuilder::of($userManager)
                        ->grant([
                             'name' => 'can_create',
                             'description' => 'The abilitiy to create a user',
                             'action' => 'create',
                             'entity' => \App\Models\User::class,
                         ]);

// Or take it off
$ability = Ability::first();

$storm = RoleBuilder::of($userManager)->takeOff($ability);


// bless the user with the abilities of the role
$user->roleManager()->blessWith($storm);


// check if it has the ability
$user->roleManager()->owns($ability);

// check if it has one of the provided abilities
$user->roleManager()->ownsOneOf([$ability, $anOtherAbility]);

// make it human again (remove its role)
$user->roleManager()->humanize();

You can also manage the instances directly

// Create Ability
$ability = Ability::create([
    'name' => 'post_write',
    'description' => 'Abitlity to create new Posts',
    'action' => 'add',
    'entity' => \App\Models\Post::class,
]);

// Create a Marvel
$writer = Role::create([
    'name' => 'Webmaster',
    'description' => 'A Role that allows you create new posts'
]);

// Grant the ability
$writer->grant($ability);

// remove a certain ability
$writer->takeOff($ability);

// remove all and keep only those
$abilities = [1, 2]; // or the models
$writer->keep($abilities);

// bless it to our user
$user = \App\Models\User::first();

$user->roleManager()->blessWith($writer);

Am I missing something?

Submit a PR or issue with details!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].