Giter VIP home page Giter VIP logo

xacmlbundle's Introduction

Code Climate Test Coverage Build Status

GalmiXacmlBundle

The GalmiXacmlBundle adds support for ABAC (Attribute Based Access Control) based on eXtensible Access Control Markup Language (XACML) Version 3.0 OASIS Standard.

Features include:

  • Policies can be stored via Doctrine ORM
  • Unit tested

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require galmi/xacmlbundle "dev-master"

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Galmi\XacmlBundle\GalmiXacmlBundle(),
        );

        // ...
    }

    // ...
}

Using with default configuration

With default configuration it is Permit to all resources and actions if it is not denied.

You must determine Resource for each action. You can add Annotation for your actions.

<?php

namespace AppBundle\Controller;

// ...
use Galmi\XacmlBundle\Annotations\XacmlResource;

class CustomerController extends Controller
{
    /**
     * @XacmlResource(entity="AppBundle\Entity\Customer", id="id")
     */
    public function editAction(Request $request)
    {
      // ...
    }
}

This annotation determine resource class "AppBundle\Entity\Customer" with identifier key "id" in request (_GET, _POST).

Customization

Configure Default Decision

Default decision is determine the result of request if rules was not matched. Default value is "Permit". It's mean that user will restrict access to all requests if all rules is not match request. Default decision value allowed "Permit" or "Deny".

# config/parameters.yml

parameters:
  galmi_xacml.default_decision: Permit

If you using xml configuration, you can use constant PERMIT or DENY of class Galmi\Xacml\Decision.

<!-- config/services.xml -->

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services
        http://symfony.com/schema/dic/services/services-1.0.xsd">
    <parameters>
        <parameter key="galmi_xacml.default_decision" type="constant">Galmi\Xacml\Decision::PERMIT</parameter>
    </parameters>
</container

Configure Default Combining Algorithm

If you have multiple top level Policy sets or Policies, Policy Decision Point must determine only one decision "Permit" or "Allow". For this case you can use Combining Algorithm. Default value is "\Galmi\Xacml\CombiningAlgorithmRegistry::FIRST_APPLICABLE" it means that first evaluated Policy set or Policy is the result of PDP.

# config/parameters.yml

parameters:
  galmi_xacml.default_combining_algorithm: "first-applicable"

If you using xml configuration, you can use constants of class Galmi\Xacml\CombiningAlgorithmRegistry.

<!-- config/services.xml -->

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services
        http://symfony.com/schema/dic/services/services-1.0.xsd">
    <parameters>
        <parameter key="galmi_xacml.default_combining_algorithm" type="constant">\Galmi\Xacml\CombiningAlgorithmRegistry::FIRST_APPLICABLE</parameter>
    </parameters>
</container

xacmlbundle's People

Contributors

galmi avatar

Watchers

 avatar  avatar

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.