Skip to content
/ casbin Public

Use Casbin in Symfony Framework, Casbin is a powerful and efficient open-source access control library.

License

Notifications You must be signed in to change notification settings

videni/casbin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

videni/casbin

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Use Casbin in Symfony Framework, Casbin is a powerful and efficient open-source access control library. Built on top of php-casbin/php-casbin and php-casbin/database-adapter

Installation

1. Add videni/casbin as your dependency

composer require videni/casbin:"^1.0@dev"

2. Configure your enforcers

videni_casbin:
    default_enforcer: mysql
    enforcers:
        mysql:
            path: "%kernel.project_dir%/config/packages/videni_casbin/rbac_with_domains_model.conf"
            adapter: mysql
    adapters:
        mysql:
            class: Videni\Casbin\Adapter\DatabaseAdapter
            options:
                type: "mysql"
                hostname: "db"
                database: "zaizai"
                username: "zaizai"
                password: "zaizai"
                hostport: "3306"

3. Install database tables if you use DatabaseAdapter

bin/console videni-casbin:install mysql

the mysql is your adapter name

Usage

1. Casbin enforcer

you can get the default enforcer by videni_casbin.default_enforcer, others are managed by EnforcerManager.

/** @var \Videni\Casbin\EnforcerManager $enforcerManager **/
$enforcerManager->getEnforer('mysql'); //  return the default enforcer if no argument provided.

2. Symfony security voter - CasbinVoter

A Symfony security voter which uses the default casbin enforcer.

About

Use Casbin in Symfony Framework, Casbin is a powerful and efficient open-source access control library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages