|
3 | 3 |
|
4 | 4 | 
|
5 | 5 |
|
6 |
| -## Overview |
7 |
| -### Goal |
| 6 | +## Goal |
8 | 7 | Provide a simple method of managing ACL in a Laravel application built on the Laravel Authorization functionality.
|
9 | 8 | By leveraging Laravel's native Authorization functionality there is no additional learning or implementation curve. All
|
10 | 9 | you need to know is Laravel, and you will know how to use Governor for Laravel.
|
11 | 10 |
|
12 |
| -### Reasoning |
13 |
| -I was looking for a straight-forward approach to ACL management that didn't require extensive customization, |
14 |
| -configuration, or even project rewrites. The following criteria shaped the development of this package: |
15 |
| -- Provide drop-in capability, so you can equally add it to existing or new Laravel projects without issues. |
16 |
| -- Allow granular access management, yet keep it simple to use. |
17 |
| -- Provide an administrative front-end out-of-the box. |
18 |
| - |
19 |
| -### Considerations |
20 |
| -#### User Requirements |
21 |
| -- You must have at least 1 (one) user in your users table. The user with the lowest ID will become your admin by default. |
22 |
| - This can be changed after the installation, of course. |
23 |
| - |
24 |
| -#### Tables |
25 |
| -You must add a `created_by` column to each of your tables. I purposefully chose not to write a 'magical' migration that |
26 |
| -would do all this for you, as that could lead to problems. However, I have added such a migration at the end to give you |
27 |
| -a solid starting point. |
28 |
| - |
29 |
| -#### User Model |
30 |
| -Your user model (most often `User.php`) should implement the Governable and Authorizable traits: |
31 |
| -```php |
32 |
| -<?php namespace App; |
33 |
| - |
34 |
| -use GeneaLabs\LaravelGovernor\Governable; |
35 |
| -use Illuminate\Auth\Authenticatable; |
36 |
| -use Illuminate\Auth\Passwords\CanResetPassword; |
37 |
| -use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; |
38 |
| -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; |
39 |
| -use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; |
40 |
| -use Illuminate\Database\Eloquent\Model; |
41 |
| -use Illuminate\Foundation\Auth\Access\Authorizable; |
42 |
| - |
43 |
| -class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract |
44 |
| -{ |
45 |
| - use Authenticatable; |
46 |
| - use Authorizable; |
47 |
| - use CanResetPassword; |
48 |
| - use Governable; |
49 |
| - |
50 |
| - // [...] |
51 |
| -} |
52 |
| -``` |
53 |
| - |
54 |
| -#### Models |
55 |
| -The `create` methods in your models will automatically add the created_by user ID. To prevent this, add the following to |
56 |
| -your models that do not have a `created_by` column in their table: |
57 |
| -```php |
58 |
| - protected $isGoverned = false; |
59 |
| -``` |
60 |
| - |
61 |
| -#### Routes |
62 |
| -This package adds multiple routes under `genealabs/laravel-governor`. Please verify that these don't collide with any of |
63 |
| -your existing routes. |
64 |
| - |
65 |
| -#### Policies |
66 |
| -Your policy classes must extend `GeneaLabs\LaravelGovernor\Policies\LaravelGovernorPolicy`, and call the |
67 |
| -`validatePermissions` method. Please see the example policy class below. As you can see, all your policies are very |
68 |
| -straightforward, clean, and easy to understand. Governor and Laravel take care of all the dirty work for you. |
69 |
| - |
70 |
| -## Features |
71 |
| -Governor for Laravel takes full advantage of the Authorization functionality added to Laravel 5.1.12 and provides full |
72 |
| -User/Roles management. It lets you specify the policies using the native Authorization mechanisms, and lets you |
73 |
| -granularly manage user access to the various parts of your system. |
74 |
| - |
75 |
| -### Entities |
76 |
| - |
77 |
| -You define a list of entities, named after your Policy classes. This is not a requirement, but helps keep things organized. |
78 |
| - |
79 |
| -### Roles |
80 |
| - |
81 |
| -Roles are basically your user-groups. Two roles are created out of the box (these cannot be removed): |
82 |
| -- Superadmin: is set up with the user with the lowest ID by default. You can add more users as necessary. |
83 |
| -- Members: all users are by default members. You cannot remove users from the Members group. |
84 |
| - |
85 |
| - |
86 |
| -Editing each role will let you specify granular access to each policy. |
87 |
| - |
88 |
| -### Assignments |
89 |
| - |
90 |
| -Assignments tie users to roles; this is where you add and remove users to and from roles. |
| 11 | +## Documentation |
| 12 | +Please see https://governor.forlaravel.com for complete documentation. |
91 | 13 |
|
92 | 14 | ## Installation
|
93 | 15 | ```sh
|
|
0 commit comments