journeycx/authuser 问题修复 & 功能扩展

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

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

journeycx/authuser

Composer 安装命令:

composer require journeycx/authuser

包简介

AuthUser - Laravel Routes Authorization Library

README 文档

README

AuthUser is flexible authorization system for Laravel, It checks the route permission to access a certain portion of the site or application. To add Permissions User-based, Role-based, Conditionally. It uses authority.checkpost middleware for filter permission of current accessing route, Under this middleware checked every permission of the user login.

Installation

Require this package in your composer.json or install it by running:

    composer require journeycx/authuser

Now, insert this line into your config/app.php under the provider array.

    journeycx\AuthUser\AuthUser::class

Now, run this command after that config/authuser.php and app/Http/Middleware/AuthUserCheckpostMiddleware.php files are publish.

    php artisan vendor:publish  --tag="authuser"

Now, insert this line into your app/Http/Kernel.php under the $routeMiddleware array.

    'authority.checkpost'  => \App\Http\Middleware\AuthUserCheckpostMiddleware::class

Use authority.checkpost middleware for handle permission base routes.

    Route::group(['middleware' => 'authority.checkpost'], function () {
        // Place all those routes here which needs authentication and authorization.
    });

Now, the basic setup is ready you need to configure rules of permissions using config/authuser.

Configuration

The structure of permissions given below, but it's highly recommended to read more on docs`.

    [
        'allow' => ['*'], // Allowed permission to user. Priority is less than deny.
        'deny'  => ['temp1'], // Deny permission to user. Priority is higher than allow.
    ]

    canAccess('temp1');
    // false 

Usage - Helpers

  • canAccess($accessId = null);
    Check the access, By default it check current route and return response in boolean value.
    canAccess('temp1');
    // true or false
  • canPublicAccess($accessId = null); - Authentication not required
    Check the public access, By default it check current route and return response in boolean value.
    canPublicAccess();
    // true or false

Usage - Facade

  • AuthUser::check($accessId = null, $requestForUserId = null)
    Check the access of $accessId, By default it check current route and return response in boolean value, And it can check access of perticular user by passing user id ($requestForUserId) parameter.
    AuthUser::check('temp1');
    // true or false
  • AuthUser::isPublicAccess($accessId = null); - Authentication not required
    Check the access of $accessId, By default it check current route and return response in boolean value.
    AuthUser::isPublicAccess('temp1');
    // true or false

Usage - Directives

  • @canAccess($accessId = null);
    Check the access, By default it check current route and return response in boolean value.
    @canAccess()
       // your logic here.
    @endAccess;
  • @canPublicAccess($accessId = null); - Authentication not required
    Check the public access, By default it check current route and return response in boolean value.
    @canPublicAccess()
       // your logic here.
    @endAccess;

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-12