2017 © Pedro Peláez
 

cakephp-plugin permissions-component

Permissions component

image

label305/permissions-component

Permissions component

  • Monday, October 31, 2016
  • by tscheepers
  • Repository
  • 3 Watchers
  • 2 Stars
  • 1,101 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Permissions Component Build Status

Eases up fetching CRUD permissions from models., (*1)

No maintenance intended, (*2)

This project is no longer actively maintained. It does its job, but there are no plans to extend or change it., (*3)

Install

Add the repository to your requirements and load using composer, (*4)

    "require": {
        "label305/permissions-component": "dev-master"
    }

Add to your app's components, (*5)

public $components = array(
    'PermissionsComponent.Permissions'
);

Usage

Setup authentication using the Auth component and define a user model, (*6)

public $components = array(
    'Auth' => array(
        'authenticate' => array(
            'Form' => array(
                'userModel' => 'YourUserModel'
                )
            )
        )
    );

After that the Permissions component will use the YourUserModel as the PermissibleModel passed in the options to your CRUD methods., (*7)

For example:, (*8)

public function canUpdate($options) {
    $result = false;

    switch($options['PermissibleModel']) {
        case 'PermAccount':
            if(isset($options['PermissibleId'], $options['id'])) {
                $this->id = $options['id'];
                $result = $this->field('perm_account_id') == $options['PermissibleId'];
            }
        break; 
    }
    return $result;
}

This will check if the requested item with $options['id'] has the perm_account_id matching to the logged in user. It is possible to do authentication with multiple models, when, for example, you also want to define permissions to something like an api key. You only need to change the userModel used by the Authentication component, (*9)

Admin users

For convenience you can define an "isAdmin" method in your user model, when the method is defined the permissions component will always first poll this method. If the method returns true, it will allow the authenticated user to do everything., (*10)

License

Copyright 2014 Label305 B.V., (*11)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at, (*12)

http://www.apache.org/licenses/LICENSE-2.0, (*13)

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License., (*14)

The Versions

31/10 2016

dev-master

9999999-dev http://www.label305.com

Permissions component

  Sources   Download

The Requires

 

by Joris Blaak

component cakephp permissions crud

03/04 2014

dev-hotfix_isadminfix

dev-hotfix_isadminfix http://www.label305.com

Permissions component

  Sources   Download

The Requires

 

by Joris Blaak

component cakephp permissions crud

01/04 2014

dev-feature_doc

dev-feature_doc http://www.label305.com

Permissions component

  Sources   Download

The Requires

 

by Joris Blaak

component cakephp permissions crud