GithubHelp home page GithubHelp logo

matiasiglesias / csnauthorization Goto Github PK

View Code? Open in Web Editor NEW

This project forked from coolcsn/csnauthorization

0.0 2.0 0.0 246 KB

Authorization module for Zend Framework 2

License: BSD 3-Clause "New" or "Revised" License

PHP 100.00%

csnauthorization's Introduction

CsnAuthorization

What is CsnAuthorization?

CsnAuthorization is an Authorization module based on Access Control List and DoctrineORMModule.

What exactly does CsnAuthorization do?

CsnAuthorization has been created with educational purposes to demonstrate how Authorization can be done. It is fully functional. Authorization is the process of giving access rights to a user on a set of resourses(in our case - controllers) and determining their privileges(in our case - actions) on those resourses.

What's the use again?

An alternative to BjyAuthorize, working in perfect harmony with Doctrine and the other Csn modules.

Installation

  • Installation via composer is supported, simply run (make sure you've set "minimum-stability": "dev" in your composer.json file): php composer.phar require coolcsn/csn-authorization:dev-master
  • Configure referenced module (CsnUser) following its instructions.
  • Add 'CsnAuthorization' to your application configuration in config/application.config.php. An example application configuration could look like the following:
'modules' => array(
    'Application',
    'DoctrineModule',
    'DoctrineORMModule',
    'CsnUser',
    'CsnAuthorization'
)
  • Set up your Access Control List configuration by copying acl.global.php.dist (located in vendor/coolcsn/csn-authorization/config if you have installed via Composer) into your config/autoload directory (Remove the .dist part).
  • Recommended: Run ./vendor/bin/doctrine-module orm:schema-tool:update to update the database schema if you are going to store the ACL in the database (Note: You may need to force the update by adding --force to the command).
  • Optional: If you prefer to load the ACL from the database, make sure you've completed the previous step, then set use_database_storage = true in the acl config. Import the sample ACL located in ./vendor/coolcsn/CsnAuthorization/data/SampleData.sql. You can easily do that with PhpMyAdmin for instance.

Does it work?

Navigate to a controller/action which has been allowed only for members in your ACL configuration and you should be redirected. Now login (preferably using CsnUser) and attempt that action again. Enjoy :)

Important Notes

  • Wherever you need the acl object, just call $serviceLocator->get('acl'). It will properly construct a Zend\Permissions\Acl\Acl object based on the data in the config or the database.
  • In your controllers or view scripts you can call $this->isAllowed($resource, $privilege) to check whether the current user has access to a resource.

Dependencies

This Module depends on the following Modules:

  • DoctrineORMModule
  • CsnUser (Decoupling - coming soon!!!)

Recommends

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.