keboola/permission-checker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

keboola/permission-checker

最新稳定版本:2.10.0

Composer 安装命令:

composer require keboola/permission-checker

包简介

Keboola K8S client library

README 文档

README

Generic permissions checker that centralizes all permission checks in one place.

Usage

Library provides Keboola\PermissionChecker\StorageApiTokenInterface interface that is expected to be implemented by caller (or provided by some other compatible library). The token is then passed to Keboola\PermissionChecker\PermissionChecker along with concrete checker for the action to be validated.

If the check passes, script execution continues normally. If the check fails, Keboola\PermissionChecker\Exception\PermissionException is thrown with a message that describes the reason of the failure and is safe to be presented to a user.

use Keboola\PermissionChecker\PermissionChecker;
use Keboola\PersmissionChecker\Checker\JobQueue\CanRunJob;

$storageToken = new MyStorageApiClass(...)

$checker = new PermissionChecker();
$checker->checkPermissions($storageToken, new CanRunJob(BranchType::DEFAULT, 'keboola.component-id'));

Development

Prerequisites:

  • installed docker to run & develop the library

TL;DR:

docker compose run --rm dev-permission-checker composer install
docker compose run --rm dev-permission-checker composer ci

Implementing new checker

Each action that needs to be validated has its own checker - a class implementing Keboola\PermissionChecker\Checker\PermissionCheckerInterface. The interface has just a single method checkPermission which receives Keboola\PersmissionChecker\StorageApiToken instance (different class that the token passed to Keboola\PermissionChecker\PermissionChecker::checkPermissions()!) and throws Keboola\PermissionChecker\Exception\PermissionException if the check fails.

If the checker requires any additional data or depends on some other service, it is free to require it through its constructor.

License

MIT licensed, see LICENSE file.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 8
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-15