定制 cyrixbiz/acl 二次开发

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

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

cyrixbiz/acl

Composer 安装命令:

composer require cyrixbiz/acl

包简介

An Access Control List for Laravel without Gates

README 文档

README

With this ACL is it possible to protect routes as well as single methods / functions It's possible to give Single authorizations to users or to divide into roles which can also get single authorizations.

Install the ACL

  • Composer

    composer require cyrixbiz/acl dev-master
  • Edit config\app and add the following lines

    'providers' => [
    // ...
    cyrixbiz\acl\AclServiceProvider::class,
    // ...
    ];
  • Got to your User Model - Default Value: App\Models\User.php and set this

    //after namespace .....
    use cyrixbiz\acl\traits\hasRelation;
    
    //after Notifiable in Class
    //for Example: use Notifiable, hasRelation;
    
    , hasRelation;
  • Install all

    php artisan make:acl
  • Install a Single Method

    • Allow Arguments:

      • setAuth ( Laravel Auth )
      • setRoutes ( ACL Routes to web.php )
      • setResourceFiles ( Lang and View Files)
      • setTables ( Set Database Tables )
      • setSeeds ( Insert Database Seeds)
      • setAdmin ( Set an Admin )
    • Allow Options

      • setAdmin --admin=Adminname --admin=AdminMail --admin=AdminPassword

        Rules = Name 5 Letters Email Valid-Email and Unique Password = Min. 8 Signs and 3 of 4 Rules 1 Low- and 1 Upper- Case / 1 Number / Special Chars

    php artisan make:acl argument
  • Edit App\Http\Kernel and add the following lines

    protected $middlewareGroups = [
      //
    'acl' => [\cyrixbiz\acl\Http\Middleware\Acl::class,
            ],
  • Error - Handling

    Exception: PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")

    Fix this Issue:

    • App\Providers
    // after namespace
    use Illuminate\Support\Facades\Schema;
    // Inside Boot-Method
    Schema::defaultStringLength(191);

Config - File

  • ACL

    • Enable / Disable the Routeprotection

      'enable' => true | false
    • Method to check the Routes

      'method' => getActionName | getName

      Description: If i use the method 'getActionName', the controller will be used and dissolved for the determination of the resources. Out of the rolecontroller@index it will create role.index. If u use the method 'getName', the alias of the controller will be used for the determination.

      'fallback' => getActionName | getName

      Description: Set a Fallback to Check the Method

    • Set a Secure User

      'superAdmin' => 1 - UserID

      Description: This User has Full Rights and can't be deleted

    • Set a newMemberRole

      'newMemberRole' => 3 - UserID

      Description: Members receive this Role after an active registration

    • Set a Blocked Role

      'blockedRole' => 5 - RoleID

      Description: This Role has zero Rights and can't be deleted. Set a User to this Role and all other Roles and Resources will be deleted.

  • Cache

    • Set Cache Time in Seconds
      'time' => '60'

      Description: This Method set the Time to Cache the User-Resources

Usage

Middleware

For Example: Set this to your Route-File and all routes in this group are checked

  • routes/web
Route::middleware(['web' , 'acl'])
    ->group(function () {
        Route::get('user', 'cyrixbiz\acl\controller\UserController@index')
            ->name('user.index');
});
Blade

For Example: Single Check @perm @endperm

@perm('user.index')
    <a class="btn btn-xs btn-warning" href="#">Anzeigen</a>
@endperm

For Example: Multi Check @perms @endperms

@perms(['acl.getPermissions' , 'role.user'])
<a class="btn btn-xs btn-success" href="#">Anker</a>
@endperms

For Example: Multi Check, One must true @orPerms @endorPerms

@orPerms(['acl.getPermissions' , 'role.user'])
<a class="btn btn-xs btn-success" href="#">Anker</a>
@endorPerms
Requirements

cyrixbiz/acl 适用场景与选型建议

cyrixbiz/acl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 03 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 cyrixbiz/acl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cyrixbiz/acl 我们能提供哪些服务?
定制开发 / 二次开发

基于 cyrixbiz/acl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-03-13