Git Product home page Git Product logo

abac's Introduction

PHP Attribute Based Access Control (ABAC)

A simple framework for implementing ABAC in your application.

Rules

Rules implement business logic, the input for rule execution consists of:

  • source: The actor, usually the current user
  • target: The subject, the entity that the actor wishes to act upon
  • permission: The action the actor wishes to take
  • environment: The environment should contain anything else the business rules may need

Rules are encouraged to do recursive access check. A typical rule could be WriteImpliesRead, since for most systems when you can write an object you can also read it. Implementation could look like this:

public function execute(
    object $source,
    object $target,
    string $permission,
    Environment $environment,
    AccessChecker $accessChecker
): bool {
    return $permission === 'read' && $accessChecker->check($source, $target, 'write');
}

Environment

Consider a rule that allows access only during office hours. The current time should then be set in the environment. Reasoning behind this is that having 1 location for the environment allows for easy testing as well as a single source of truth.

Infinite loops

Rules can contain infinite loops, we track recursion depth to detect these loops.

External links

abac's People

Contributors

sammousa avatar dependabot[bot] avatar sohelahmed7 avatar

Stargazers

mo die avatar Igor avatar João Sales avatar Joey Claessen avatar  avatar

Watchers

 avatar James Cloos avatar Viktor Yasinefta avatar

abac's Issues

Allow source and target to be `null`

public function isAllowed(Authorizable $source, Authorizable $target, string $permission)

Volgens mij moet het ook mogelijk zijn om null als source en target mee te geven. Null source om te kunnen ondersteunen dat je rechten vraagt over een gebruiker die niet ingelogd is. Null target om op te kunnen vragen of de gebruiker een rol heeft zonder dat daar verder iets aan gekoppeld hoeft te zijn.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.