Support the ongoing development of Laravel.io →
Security Packages Authentication
Last updated 2 years ago.
0

Hi! Thank you for your demo application.

How can i set permissions by Role. not by user_id?

Last updated 2 years ago.
0

JETSA said: How can i set permissions by Role. not by user_id?

Hi Serhat,

You means permissions stored in database ?

Otherwise, in the Authority-Controller config file, you can set authorizations by role using:

if ($user->hasRole('moderator')) {
    $authority->allow('manage', 'Post');
}

For more information, you can read this Wiki doc: Defining Authority rules.

Cheers, Tortue Torche.

Last updated 2 years ago.
0

thank you for your post tortuetorche. You wrote $authority->allow('manage', 'Post'); by hand. I want store in database that informations. Table -> actions[id, name, desc] Table -> permissions[id, type, action_id, resource ]

How can i do that?

Last updated 2 years ago.
0

I don't have a turnkey solution for you, you need to tweak the code provides in config.php

//...
// Loop through each of the users permissions, and create rules:
foreach($user->permissions as $perm) {
 if ($perm->type == 'allow') {
     $authority->allow($perm->action, $perm->resource);
 } else {
     $authority->deny($perm->action, $perm->resource);
 }
}
//...

This feature belongs to Authority-L4 package. You can read the doc here and see the permissions table structure here.

Then you can tried to use this user permissions system and port it to the roles table. The Eloquent Pivot Table and Polymorphic Relations docs should help you.

But the main goal of Authority-Controller, like CanCan, is to not have permissions stored in database.

Last updated 2 years ago.
0

@dudzio12 writes a tutorial to store roles permissions in database: http://laravel.io/bin/5WMxJ

In addition, You need to rewrite these migration files: https://github.com/machuga/authority-l4/tree/2.2.0/src/migrations

Me or @dudzio12 will write a complete tutorial later.

Last updated 2 years ago.
0

I just released Authority-Controller 1.2.4 to fix Functional tests with Codeception.

So you can update the package, like this:

composer update efficiently/authority-controller

Then you need to follow these instructions and finally you can play with functional tests of Codeception!

Last updated 9 years ago.
0

Hey tortuetorche, thanks for your work on this, it's a great package, it's working great for me. I am in the early stages of a new project and debating whether I should build on Laravel 5 or not, wondering if Authority Controller will support Laravel 5, and if so, when it would be ready?

0

Hi Tim,

Laravel 5 is not released yet and I plan to support it only when it'll be stable (~1 or 2 months after its official release, I hope).

Generally when a major release of framework come's out, you need to wait a couple weeks or a couple of months to get all the plugins/packages up to date.

Cheers, Tortue Torche

Last updated 9 years ago.
0

Authority-Controller 2.0 now supports Laravel 5.0!

It's an alpha release, so you need to tweak the composer.json file of your Laravel 5 application.

Add a repositories option:

{
	//...
	"repositories": [
		{
			"type": "vcs",
			"url": "https://github.com/stayallive/authority"
		},
		{
			"type": "vcs",
			"url": "https://github.com/stayallive/authority-l5"
		}
	],
	//...
}

Then add these two options:

{
	//...
	"prefer-stable": true,
	"minimum-stability": "dev"
}

Here a composer.json sample.

Last updated 9 years ago.
0

The easiest way to play with Authority-Controller 2.0, is to git clone my Laravel 5.0 demo application:

git clone https://github.com/efficiently/laravel_authority-controller_app --branch 2.0 && cd laravel_authority-controller_app

Then inside the application's root, run these commands:

composer install
php artisan serve

In your Web browser, go to this URL: http://localhost:8000/users

You should see an AccessDenied exception.

With this error message: You are not authorized to access this page..

Go to: http://localhost:8000/auth/login

Fill the login form with [email protected] and password then click on the Login button.

You should see: You are logged in!.

Then go back to: http://localhost:8000/users

You should see: Administrator.

Now, You can read the doc to add more authorization rules.

Last updated 9 years ago.
0

Authority-Controller 2.1 now supports Laravel 5.1!

It's a beta release, so you need to tweak the composer.json file of your Laravel application.

Add these two options:

{
	//...
	"prefer-stable": true,
	"minimum-stability": "dev"
}

Here a composer.json sample.

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.