hello! here's a little about me:
These are some major technologies that I use or have worked on in the past:
Programming Languages
Libraries and Frameworks
Databases
Cloud
DevOps
Tools
Simple RBAC/ACL for Laravel 8 caching and permission groups.
License: MIT License
Currently when a permission is not related to a user the code redirect to /page welcome by default, for this i suggest add a variable in the config file to put the value than each project need in my case was the page /home.
Thanks for your atention.
Route::middleware(['role:admin'])->group(function () {
Route::get('/admin', function () {
// Uses admin role
});
});
is there anything like
Route::middleware(['permissiongroup:somepermissiongroup'])->group(function () { Route::get('/admin', function () { // Uses first & second Middleware }); });
While following the steps of Readme.MD i found that when i run php artisian miragte
it throws error:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'pe
rmission_permission_group_permission_id_permission_group_id_primary' is too
long (SQL: alter table `permission_permission_group` add primary key `perm
ission_permission_group_permission_id_permission_group_id_primary`(`permiss
ion_id`, `permission_group_id`))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'pe
rmission_permission_group_permission_id_permission_group_id_primary' is too
long
Hi guys,
Good work.
How ever, I come across this issue when I'm trying to implement this.
I am trying this on a fresh laravel installation with only change of Models having their own folder called Models.
Therefore, models are in App\Models.
I have updated this in the auth config file/section.
Logins, and registrations are working.
My issue comes up when I'm trying to check if a user has permission.
My code is
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use App\Models\User;
class RequestController extends Controller
{
public function index(){
$user = Auth::user();
if ($user->canDo('product.create')) {
}
}
}
However, I come across the error
BadMethodCallException
Method Illuminate\Database\Query\Builder::permissionsArray does not exist.
Any help is greatly appreciated.
try
@ifUserCan('product.create')
// show product create content
@endif
but It doesn't work
Note: I added role 'admin' and role_user also added 'pruduct.create' in the permissions table
How can I add child roles for a role like Yii2 framework here.
http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#using-migrations
$author = $auth->createRole('author');
$auth->add($author);
$auth->addChild($author, $createPost);
$admin = $auth->createRole('admin');
$auth->add($admin);
$auth->addChild($admin, $updatePost);
$auth->addChild($admin, $author);
hi, it's an excellent work, however i found a mistake beacuse when y tried to use smething like:
Route::get('/', [
'uses'=>'UsersController@index',
'middleware'=>'permission:users.user.index',
'as'=>'users.user.index'
])->middleware('auth');
the code didn't fidn de permission, so i was looking for the problem. In the file namespace YaroslavMolchan\Rbac\Helpers\CacheHelper line 13 appear this if (false === \Cache::has($key)) { and i changed it for if (true === \Cache::has($key)) { whit this the code could find a permission related to the permission group and a permission related to a role both related to the same user.
As shown in the readme the installation instructions for Laravel 8.x, i tried to add the rbac^2.0 dependency and tried to run composer, but it couldn't find a suitable package. Here's the config and the output:
composer.json
{
"name": "ssom/ssom",
"type": "project",
"description": "Simple Service Order Managent",
"keywords": ["order management"],
"license": "Beerware",
"require": {
"php": "^7.3|^8.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.40",
"laravel/tinker": "^2.5",
"yaroslavmolchan/rbac": "^2.0"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/breeze": "^1.3",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
and the output:
$ composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires yaroslavmolchan/rbac ^2.0, found yaroslavmolchan/rbac[dev-master, 0.9.0, ..., 0.9.x-dev, 1.0.0, 1.0.1, 1.0.2, 1.0.3] but it does not match the constraint.
Is v2 available? If not yet, any hints when it will be?
Your package seems nice, thanks for sharing!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.