Skip to content

Commit

Permalink
Merge pull request #37 from savannabits/develop
Browse files Browse the repository at this point in the history
Final Documentation Review for v2.0.0 release:
  • Loading branch information
coolsam726 authored Jul 21, 2023
2 parents 12d7f9a + 741aa90 commit 67feb9a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Fix PHP code style issues

on:
push:
branches: [ main ]
pull_request_target:
branches: [ main ]
pull_request:
branches: [ develop ]

jobs:
php-code-styling:
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ class UserResource extends Resource
use ContextualResource;
}
```
## Access, Roles and Permissions
For Access Control, this package is designed to work hand in hand with
**[Shield (Roles & Permissions)](https://github.com/bezhanSalleh/filament-shield)** by [Bezhan Salleh](https://github.com/bezhanSalleh), which is a wrapper around
**[spatie/laravel-permission](https://github.com/spatie/laravel-permission)**.

If you don't have the two packages above installed, then Modules will ignore access control and by default allow access to anyone logged in.

With Shield, the package adds two more functionalities:
1. Generates permissions to allow access to the module. These are prefixed with `module_`. For example, if a user doesn't have the permission `module_Blog` then they won't be able to access any contexts under the `Blog` module.
![img_6.png](img_6.png)
2. Enables shield to scan for resources and pages registered under the contexts in `Modules` in addition to the default Filament installation and generate permissions for them. If the policies generation option is enabled, the Policy classes are also generated under `Modules\ModuleName\Policies\`.
![img_5.png](img_5.png)

### WIP
Currently, the permissions for all pages in the various modules are named as page_{BaseClassName}. This brings challenges in case there are pages named similarly but in different contexts. The plan is to override the naming as is in `Shield` so that it can also capture the full path of the page class.

## Testing

Expand Down
Binary file added img_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/FilamentModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static function registerFilamentNavigationItem($module, $context): void

public static function hasAuthorizedAccess(string $context)
{
if (! app()->has('filament-shield')) {
if (! (app()->has('filament-shield') && \DB::table(config('permission.table_names.permissions'))->exists())) {
return true;
}
$module = Str::of($context)->before('-')->lower();
Expand Down

0 comments on commit 67feb9a

Please sign in to comment.