chore: add service account, use spatie permissions and roles#139
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Spatie roles/permissions (and Filament Shield integration) to support a “service-account” role and use it to bypass certain group-membership checks in the external API.
Changes:
- Introduces Spatie permission config + migrations and adds
HasRolestoUser. - Integrates
bezhansalleh/filament-shieldinto the Filament admin panel and adds aRolePolicy. - Updates API authorization to allow users with the
service-accountrole to access/modify instances across groups.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| database/seeders/ServiceAccountRoleSeeder.php | Adds a seeder to create the service-account role. |
| database/migrations/2026_05_13_132126_create_permission_tables.php | Adds Spatie roles/permissions database tables. |
| config/permission.php | Adds Spatie permission package configuration. |
| composer.json | Adds spatie/laravel-permission and bezhansalleh/filament-shield dependencies. |
| composer.lock | Locks new dependencies and related version updates. |
| app/Providers/Filament/AdminPanelProvider.php | Registers the Filament Shield plugin in the admin panel. |
| app/Policies/RolePolicy.php | Adds policy for Role model authorization. |
| app/Models/User.php | Enables Spatie roles/permissions on the User model via HasRoles. |
| app/Http/Controllers/Api/AuthenticatedApiController.php | Allows service-account role to bypass group-membership checks for certain endpoints. |
Comments suppressed due to low confidence (2)
app/Policies/RolePolicy.php:91
- These restore permission checks still use template placeholders ("{{ Restore }}" / "{{ RestoreAny }}"), which will not match any real permission names. Update them to the intended permission strings (consistent with view/create/update/delete patterns, e.g. restore_role / restore_any_role).
public function restore(User $user, Role $role): bool
{
return $user->can('{{ Restore }}');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
app/Policies/RolePolicy.php:107
- These replicate/reorder permission checks still use template placeholders, so policy evaluation will not behave as intended. Replace them with concrete permission names that match the rest of the policy naming scheme (e.g. replicate_role / reorder_role).
public function replicate(User $user, Role $role): bool
{
return $user->can('{{ Replicate }}');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot address PR comments and implement fixes |
Agent-Logs-Url: https://github.com/amazeeio/polydock-engine/sessions/4d5bcb7c-0a48-405d-af76-cac186f14c3f Co-authored-by: dan2k3k4 <158704+dan2k3k4@users.noreply.github.com>
Implemented the requested PR comment fixes in commit
I also attempted to run targeted tests, but this sandbox cannot complete dependency install (GitHub auth/private package access), so only PHP syntax checks could be run locally. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
All actionable PR comments have been addressed in |
No description provided.