vima / core
Framework-agnostic RBAC + ABAC access control engine with pluggable storage backends and a built-in CLI.
Installs: 20
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 2
pkg:composer/vima/core
Requires
- php: >=8.1
- symfony/console: ^7.3
- symfony/var-dumper: ^7.3
Requires (Dev)
- pestphp/pest: ^4.1
README
Vima Core is a framework-agnostic foundation for building robust Role-Based Access Control (RBAC) and Attribute-Based Access Control (ABAC) systems in PHP.
Unlike consumer-facing packages, Vima Core is designed specifically for framework developers and system architects. It provides a "Contract-First" toolkit that you can integrate into your framework's identity and storage systems.
๐ฏ Target Audience
- Framework Integrators: Building bridges for Laravel, Tempest, CodeIgniter, etc.
- Library Authors: Requiring a lightweight, testable authorization foundation.
- Enterprise Architects: Designing custom, decoupled security architectures.
โจ Core Features
- ๐งฉ Contract-First Design: Decoupled from storage and framework specifics.
- ๐ Entity Foundation: Standardized
User,Role, andPermissionentities. - ๐ Unified Access Manager: A single entry point for both RBAC and ABAC checks.
- โ๏ธ Flexible Policies: Class-based and closure-based ABAC support.
- ๐งช Testable: Designed with dependency injection and PSR-11 compliance.
๐ฆ Installation
composer require vima/core
๐ง Technical Overview
Vima Core provides the logic; you provide the implementation.
1. Register Implementation Contracts
As a framework integrator, you implement the storage interfaces (Repositories) and register them in the Vima container.
use Vima\Core\Contracts\RoleRepositoryInterface; use Vima\Core\Contracts\PermissionRepositoryInterface; use function Vima\Core\registerMany; registerMany([ RoleRepositoryInterface::class => new YourDatabaseRoleRepository(), PermissionRepositoryInterface::class => new YourDatabasePermissionRepository(), // ... other repositories ]);
2. Authorization Checks
Once set up, authorization is simple and consistent.
use Vima\Core\Services\AccessManager; use function Vima\Core\resolve; $vima = resolve(AccessManager::class); // RBAC Check if ($vima->can($user, 'posts.edit')) { // Authorized... } // ABAC Check (with context) if ($vima->can($user, 'posts.edit', $post)) { // Authorized based on policy logic... }
3. Defining Policies (ABAC)
Policies are class-based rules for specific resources.
use Vima\Core\Contracts\PolicyInterface; class PostPolicy implements PolicyInterface { public function canEdit(User $user, Post $post) { return $user->id === $post->userId; } } $vima->registerPolicy(Post::class, PostPolicy::class);
๐ Documentation
Detailed guides for deep integration:
- Architecture Overview โ Understand the design and "The Vima Way".
- Integration Guide โ Step-by-step instructions for framework developers.
๐ Package Structure
src/
โโโ Contracts/ # Persistent layer and service interfaces
โโโ Entities/ # Core security data structures
โโโ Services/ # AccessManager, PolicyRegistry, and Managers
โโโ Support/ # Framework integration helpers
โโโ DependencyContainer.php # Vima's PSR-11 container
๐ License
This package is part of Vima PHP and is released under the MIT License.
(c) Vima PHP https://github.com/vimaphp