Git Product home page Git Product logo

rbac's Introduction

RBAC for Backend

此工具包开箱即用,集成了接口级别的权限控制模块,自带模型、数据表、中间件,只需要配置数据库账户密码即可使用。

安装

COMPOSER_MEMORY_LIMIT=-1 composer require --no-cache niro/rbac-backend

前提

  • php 需要开启 mongodb 扩展

  • 需要名为 login 的路由,例如

Route::post('auth/login', [C\Auth\LoginController::class, 'login'])->name('login');

使用说明

  • 检查是否在 env 中配置了 mongodb 数据库账密

  • 检查 config/database.phpconnection 是否配置了 mongodb,如下案例

'connections' => [
    ...
        'mongodb' => [
            'driver' => 'mongodb',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', 27017),
            'database' => env('DB_DATABASE', 'chatbot'),
            'username' => env('DB_USERNAME', ''),
            'password' => env('DB_PASSWORD', ''),
            'options' => [
                // here you can pass more settings to the Mongo Driver Manager
                // see https://www.php.net/manual/en/mongodb-driver-manager.construct.php under "Uri Options" for a list of complete parameters that you can use

                // 'database' => env('DB_AUTHENTICATION_DATABASE', 'admin'), // required with Mongo 3+
            ],
        ],

    ],
  • 执行 php artisan migrate

  • 执行 php artisan rbac:init

  • 恭喜你,完成了初始化

自定义用户模型

  1. 可以自行创建用户模型,但必须继承 Rbac\Models\AdminUser,并修改 configs/auth.php 中的 providers.admin-users.model 为您自定义的模型类

自定义控制器

请将 src/Controllers/AdminUserController.php 文件拷贝到你想存放的路径,记得修改其中的命名空间

rbac's People

Contributors

alistair-zhong avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.