ac / kalinka-bundle
Flexible authorization for your Symfony2 app
Installs: 231
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 7
Forks: 2
Open Issues: 5
Type:symfony-bundle
Requires
- php: >=5.4.0
- ac/kalinka: ~0.1
- symfony/framework-bundle: ~2.2
- symfony/security: ~2.2
Requires (Dev)
- ac/model-traits: 0.1.0
- jms/serializer-bundle: 0.12.0
- sensio/framework-extra-bundle: ~2.2
- symfony/symfony: ~2.2
This package is not auto-updated.
Last update: 2024-11-18 15:54:54 UTC
README
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 yourAppKernel
- 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