Download the PHP package zennit/abac without Composer

On this page you can find all versions of the php package zennit/abac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package abac

ABAC (Attribute-Based Access Control) for Laravel

A flexible and powerful ABAC implementation for Laravel applications.


Table of Contents

  1. Introduction
  2. Prerequisites
  3. Installation
  4. Quick Start
  5. Basic Usage
  6. API Routes
  7. Commands
  8. Configuration
  9. Database Schema
  10. Performance Monitoring
  11. License
  12. Contributing
  13. Reporting Issues & Questions

Introduction

ABAC provides fine-grained access control by evaluating attributes of users, resources, and the context of a request.

This package integrates seamlessly with Laravel to offer powerful access control mechanisms.


Prerequisites


Installation

Install the package via Composer:

Add the service provider to your bootstrap/providers.php:


Quick Start

Migrate

Setup initial data using the provided JSON files. You can use the following example JSON structure to seed your database

This example creates a policy that determines who can view posts. It allows viewing when either:

This JSON structure follows the database schema:

Note: The chains array supports nested structures where a chain can reference another chain using the chain_id field. Either chain_id or checks must be provided in a chain, but not both.

Before running the seeder

This will add the required environment variables to your .env file and create the configuration file at config/abac.php.

Run the seeder command

After seeding the database

The final step to complete the setup is to add the trait to all the classes you have defined in path_patterns in the configuration file.


Basic Usage

Here's an example of how to perform access control checks:

The can() method evaluates the access request and returns a boolean indicating whether access is granted.

The evaluate() method can be used to get detailed information about the evaluation process, look at AccessResult for more details.

The evaluation result is automatically cached using the subject ID, resource, and operation as the cache key.

Available Operators

All operators are defined in the src/Enums/Operators directory

Logical Operators

Arithmetic Operators

String Operators

Note: Make sure when creating new objects in the database, you make use of these operators, not doing so is going to make the conditions invalid. If you want us to support other operators make a PR or raise an issue


Middleware

The ABAC package uses the EnsureAccess Middleware to check whether the requesting user has the necessary permissions to access a specific resource and method.

How It Works

The middleware is automatically registered when you add the service provider to your bootstrap/providers.php file. It evaluates access requests based on the following parameters:

For more details, refer to the AccessContext class.

Accessing the Evaluation Result

After processing the request, the middleware adds the evaluation result to the request object. You can access it using $request->abac().

Usage Example

To use the middleware, simply apply it to your routes. For example:

Important Notes


API Routes

The following API routes are available for managing ABAC-related data. These routes must be protected by the abac middleware (look at Configuration for more details) and can be prefixed using the ABAC_ROUTE_PREFIX environment variable:

For Update and Create Operations

When creating or updating ABAC resources, you have flexibility in how you structure your requests, as long as they comply with the validation rules defined in the FormRequests classes. These rules ensure data integrity and proper relationships between policies, chains, and checks.

You can create complex policy structures in a single request or build them incrementally through separate API calls. The validation system will ensure that your data maintains proper hierarchical relationships and contains all required fields.

For detailed validation rules and request structure examples, refer to the FormRequest classes:

Pagination

All index responses are paginated and support the following query parameters:

The pagination response format includes both the data items and pagination metadata:

Object Attributes

Subject Attributes

Policies

Chains

Checks

To register the ABAC routes in your application, create a new service provider:

Then update the provider to register the routes:

Register your new service provider in config/app.php:


Commands

Publishing Commands

Force Options

All commands support the --force option to skip confirmations:

Cache Management


Configuration

Environment Variables

Full Configuration Options

Database Schema

Performance Monitoring

The ABAC package includes built-in performance monitoring capabilities:

Caching System

Cache Management

Performance Metrics

These monitoring tools help identify and resolve performance bottlenecks in your access control policies.


License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please read the CONTRIBUTING file for details on how to contribute to this project.


Reporting Issues & Questions

If you encounter any issues, have questions, or need assistance with the ABAC package, please feel free to open an issue on our GitHub repository:

https://github.com/zennit-dev/abac/issues

Our team monitors the issues board regularly and will respond as soon as possible. When reporting issues, please include:

This helps us address your concerns more efficiently.


All versions of abac with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^11.2
laravel/sanctum Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zennit/abac contains the following files

Loading the files please wait ....