mailnike / spark-roles

Roles and permissions for teams and users in Laravel Spark

Home Page:http://www.zinethq.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ZiNETHQ Spark Roles

Laravel 5.3 Spark 2.0 Source Build Status License

SparkRoles, based on Caffeinated Shinobi, brings a simple and light-weight role-based permissions system to Laravel Spark's Team and User models through the following ACL structure:

  • Every user can have zero or more roles.
  • Every user can have zero or more permissions.
  • Every team can have zero or more roles.
  • Every team can have zero or more permissions.
  • Roles and permissions can be shared between users and teams.
  • Optionally, users and teams with a certain role (e.g. developer) are added to the Spark developer's array.

Permissions are then inherited to the team/user through the team/user's assigned roles.

This package is a replacement for Caffeinated Shinobi when building a project based on Laravel/Spark.

Documentation

You will find user friendly documentation in the ZiNETHQ SparkRoles Wiki BEING UPDATED

Quick Installation

  1. Install the package through Composer.

    composer require zinethq/spark-roles
  2. Publish the configuration, models, and migrations into your project.

    php artisan vendor:publish --provider="ZiNETHQ\SparkRoles\SparkRolesServiceProvider"
  3. Migrate your database.

    php artisan migrate
  4. Add the service provider to your project's config/app.php file.

    ZiNETHQ\SparkRoles\SparkRolesServiceProvider::class,
  5. Add the CanUseRoles trait to your Team and/or User models, for example:

    • app\Team.php
    <?php
    
    namespace App;
    
    use Laravel\Spark\Team as SparkTeam;
    use ZiNETHQ\SparkRoles\Traits\CanHaveRoles;
    
    class Team extends SparkTeam
    {
        use CanHaveRoles;
        ...
    }
    • app\User.php
    <?php
    
    namespace App;
    
    use Laravel\Spark\User as SparkUser;
    use ZiNETHQ\SparkRoles\Traits\CanHaveRoles;
    
    class User extends SparkUser
    {
        use CanHaveRoles;
        ...
    }
  6. Optional: If you'd like to dynamically assign the Spark developer array based on team/user roles then open app\Http\kernel.php and add the following to the web middleware group:

    \ZiNETHQ\SparkRoles\Middleware\AddDevelopers::class,

    This middleware can be controlled (enabled/disabled and choose the role slug that identifies developers) in the package's configuration file.

  7. Start using roles for your Spark teams and users!

Contributing

Fork, edit, pull request. You know the drill.

Hit list

If you'd like to contribute consider helping with one of the following:

  • Add Travis CI integration
  • Add PHPUnit support
  • Add meaningful unit tests
  • Add a Kiosk based frontend for defining roles and permissions, similar to Watchtower for Shinobi

Awesome Shinobi

Caffeinated Shinobi is an awesome tool for Laravel that adds Role Based Access Control (RBAC) to your user model. There is also a cool UI for Shinobi called Watchtower. Go take a look!

About

Roles and permissions for teams and users in Laravel Spark

http://www.zinethq.com

License:Other


Languages

Language:PHP 99.1%Language:Shell 0.9%