承接 stonedz/pff2-permissions 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

stonedz/pff2-permissions

Composer 安装命令:

composer require stonedz/pff2-permissions

包简介

Manages permissions in pff2 controllers

README 文档

README

Permissions module for stonedz/pff2 controllers.

It reads permission metadata from controller classes/actions and blocks access when the logged user does not have the required permission flags.

Requirements

  • stonedz/pff2 v4
  • Doctrine ORM enabled in your app (the module reads the user model through the EntityManager)

Installation

  1. Require the module:
composer require stonedz/pff2-permissions
  1. Enable it in your app modules list.

  2. Add module configuration in your app config folder:

app/config/modules/pff2-permissions/module.conf.yaml

moduleConf:
  userClass: AnagraficaBusiness
  sessionUserId: id_user
  getPermission: getPermesso
  controllerNotLogged: Index
  actionNotLogged: index
  permissionClass: Permesso

Configuration reference

  • userClass: user model class name under \pff\models.
  • sessionUserId: key used in $_SESSION['logged_data'] for the logged user id.
  • getPermission: method called on the user instance to retrieve the permission object.
  • controllerNotLogged: redirect controller when user is not logged.
  • actionNotLogged: redirect action when user is not logged.
  • permissionClass: permission model class name under \pff\models.

Usage (native attributes)

Use attributes on controller class and/or action method.

use pff\modules\Attributes\Pff2Permissions;
use pff\modules\Attributes\Pff2PermissionsLogicalOperator;

#[Pff2Permissions(["Logged", "FatturazioneWriteable"])]
class Fatturazione_Controller extends AController
{
  #[Pff2Permissions(["Admin"])]
  #[Pff2PermissionsLogicalOperator(Pff2PermissionsLogicalOperator::OR)]
    public function editAction()
    {
    }
}

Supported attributes

  • #[Pff2Permissions(["PermissionA", "PermissionB"])]
  • #[Pff2PermissionsLogicalOperator(Pff2PermissionsLogicalOperator::AND)]
  • #[Pff2PermissionsLogicalOperator(Pff2PermissionsLogicalOperator::OR)]

If Pff2PermissionsLogicalOperator is omitted, default behavior is AND.

Backward compatibility (legacy docblocks)

Legacy docblock annotations are still supported, so existing controllers keep working:

/**
 * @Pff2Permissions ["Logged","FatturazioneWriteable"]
 */
class Fatturazione_Controller extends AController
{
  /**
   * @Pff2Permissions ["Admin"]
   * @Pff2PermissionsLogicalOperator OR
   */
  public function editAction()
  {
  }
}

The legacy variant @Pff2PermissionslogicalOperator (lowercase l) is also recognized.

Permission evaluation rules

  • Class and method permissions are merged.
  • Duplicate permission entries are removed.
  • AND: all listed permissions must be true.
  • OR: at least one listed permission must be true.
  • If no permission annotations are present, the request is allowed.

Runtime behavior

  • Not logged user: redirected to controllerNotLogged/actionNotLogged.
  • Logged user without permission: a 403 (Action not permitted) is thrown.
  • Missing ORM setup: a 500 is thrown (PermissionChecker requires Doctrine ORM to be enabled).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-10-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固