定制 sam-it/abac 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sam-it/abac

Composer 安装命令:

composer require sam-it/abac

包简介

Attribute based access control

README 文档

README

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

统计信息

  • 总下载量: 33.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 5
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-06-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固