New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

ac/kalinka-bundle

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ac/kalinka-bundle

Flexible authorization for your Symfony2 app

symfony-bundle
Source
Packagist
Version
0.1.2
Version published
Total downloads
233
Maintainers
1
Created
Source

Kalinka-Bundle

Build Status

Symfony2 bundle for Kalinka.

Installation

  • require "ac/kalinka-bundle": "~0.1.0" in your composer.json`
  • run composer update ac/kalinka
  • Instantiate AC\KalinkaBundle\ACKalinkaBundle in your AppKernel
  • Configure the bundle, described below:

Configuration

ac_kalinka:
    #default_authorizer: 'default'
    authorizers:
        default:
            authenticated_role: 'authenticated'     #optional
            anonymous_role: 'anonymous'             #optional
            roles:                                  #map roles to actions and guard policies
                authenticated:
                    document:
                        read: 'allow'
                        index: 'allow'
                anonymous:
                    document:
                        read: 'allow'
                teacher:
                    system:
                        foo: 'allow'
                    document:
                        index: 'allow'
                        create: 'allow'
                        read: 'allow'
                        update: ['owner', 'unlocked']
                        delete: ['owner', 'unlocked']
                admin:
                    system:
                        foo: 'allow'
                        bar: 'allow'
                        baz: 'allow'
                    document:
                        index: 'allow'
                        create: 'allow'
                        read: 'allow'
                        update: 'allow'
                        delete: 'allow'
                student:
                    document:
                        index: 'allow'
                        read: 'allow'

Services

The bundle registers the kalinka.authorizer service, which you can use in your app:

$document = //...get some document instance, however you do that

$authorizer = $this->container->get('kalinka.authorizer');

if (!$authorizer->can('edit', 'document', $someDocument)) {
    throw new Exception('Computer says no. :(');
}

To register guards just use the kalinka.guard tag, and specify the domain of the guard. For example:

services:
    app.guard.document:
        class: ACME\AppBundle\Authorization\DocumentGuard
        tags:
            - { name: 'kalinka.guard', tag: 'document' }

You can also configure multiple authorizers if you need them.

#TODO: document said feature

Keywords

authorization

FAQs

Package last updated on 02 Apr 2014

Related posts