Coder Social home page Coder Social logo

laravel-rbac's Introduction

#基于数据的RBAC

适用于前后端分离项目的权限管理

树形菜单 角色管理 用户管理 API管理

Install

Require this package with composer using the following command:

composer require lwj/laravel-rbac

After updating composer, add the service provider to the providers array in config/app.php

Lwj\Rbac\ServiceProvider::class,

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

Add the middleware alias routeMiddleware array in app/Http/Kernel.php

'jwt.auth' => \Tymon\JWTAuth\Http\Middleware\Authenticate::class,
'jwt.refresh' => \Tymon\JWTAuth\Http\Middleware\RefreshToken::class,

Generate the ENV option:

php artisan jwt:secret

Config

You can also publish the config file to change implementations (ie. interface to specific class) or set defaults for --helpers or --sublime.

php artisan vendor:publish --provider="Lwj\Rbac\ServiceProvider" --tag=config
php artisan vendor:publish --provider="Lwj\Rbac\ServiceProvider" --tag=assets
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"

Inside the config/auth.php file you will need to make a few changes to configure Laravel to use the jwt guard to power your application authentication.

Make the following changes to the file 'config/auth':

use Lwj\Rbac\Models\User;

And change the array:

'defaults' => [
    'guard' => 'api',
    'passwords' => 'users',
],

...

'guards' => [
    ...,
    'api' => [
        'driver' => 'token',
        'provider' => 'users',
    ],
    'rbac' => [
        'driver' => 'jwt',
        'provider' => 'users',
    ]
],

...

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => User::class,
        ],
    ],

Migration

You can also migrate tables and base data:

php artisan migrate

User

Default User:

name: [email protected]
password: 123456

'SUPER_ADMIN' env option to set super admin in this system: if you want to add new super admin,you can use '|' separator

进入docker之后 ln -sf /var/www/html/pay-php/service2/packages/laravel-rbac/public /var/www/html/pay-php/service2/public/vendor/rbac

laravel-rbac's People

Stargazers

Yoyo avatar 东子 avatar

Watchers

James Cloos avatar wangzd avatar Jiang Zhiheng 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.