Download the PHP package dmox/h-rbac without Composer

On this page you can find all versions of the php package dmox/h-rbac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package h-rbac

h-rbac

Based on native Laravel's 5 abilities. Hierarchical RBAC with callbacks.

Latest Version on Packagist Build Status Coverage Status Quality Score Total Downloads

In the process of creating my own projects I have formed an opinion about the minimum required ability of RBAC. It should allow:

Install

Keep in mind it's only for Laravel 5.1 and later.

Via Composer

Add the service provider to config/app.php

Dlnsk\HierarchicalRBAC\HRBACServiceProvider::class,

Publish some cool stuff:

with

php artisan vendor:publish --provider="Dlnsk\HierarchicalRBAC\HRBACServiceProvider"

Add roles, permissions which you need and callbacks where it needs and have fun!

Overview

This module is wrapper for authorization logic and control access to resources of Laravel 5.1 and later. Except you shouldn't define abilities, they will define automatically.

Let's describe the minimum required ability of RBAC (in my opinion).

Roles and permissions

It's clear.

Callbacks for permissions

Very common situation is to allow user to change only his own posts. With this package it's simple:

and use as

You can pass any number of parameters in callback as array.

Permission's inheritance

As you see callbacks is very useful. But what about site manager who may edit any posts? Create separate permission? But which of it we should check?

Answer is use chained (inherited) permissions. Example:

editPost -> editPostInCategory -> editOwnPost

Each of this permission put in appropriate role but we always check the first (except in very rare cases):

These permissions will be checked one by one until one of it will pass. In other case ability will be rejected for this user. So, we have many permissions with different buisnes logic but checking in code only one.

The way RBAC is served

Very popular is to use database for store roles and permissions. It flexible but hard to support. Managing of roles and permissions required backend (but stil available to change directly in DB). When we start to use inheritance for permissions it becomes too difficult for direct changing.

In other case most projects aren't large. It need only few roles and permissions, so backend becomes economically inexpedient. Thus, I believe that file driven RBAC is enough for many projects. It's visual and simple for support.

Storage of roles and permissions is on another level of logic, so DB support may be added later.

Usage

As I said h-rbac is wrapper for authorization logic of Laravel 5.1 and later. So, you can use any features of it.

From User model:

In controller:

Within Blade

@can('editPost', $post)
    <!-- The Current User Can Update The Post -->
@else
    <!-- The Current User Can't Update The Post -->
@endcan

Also in h-rbac we add directive @role which you can combine with @else

@role('user|manager')
    <!-- The current user has any role -->
@endrole

Configuration

When you publish configuration with artisan you'll have configuration class app/Classes/Authorization/AuthorizationClass.php where you should define permissions, roles and callbacks. You are free to move this file anywhere you want. Don't forget update config/h-rbac.php in this case.

Structure of configuration class:

You should add callback only if you need additional check for this permission. The name of callback should be camelcased name of permission.

We use next logic for checking permission: starting from the current permission, we check all of the following in chain one by one and:

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONDUCT for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of h-rbac with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ~5.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dmox/h-rbac contains the following files

Loading the files please wait ....