fix(auth): enforce authorization checks across API and Livewire components

- Add authorization checks to API controller endpoints (view, create, update, delete)
- Wrap Livewire component methods with try-catch for consistent error handling
- Add AuthorizesRequests trait to components requiring authorization checks
- Ensure all sensitive operations verify user permissions before execution
- Implement unified error handling with handleError() helper function
This commit is contained in:
Andras Bacsai
2026-02-25 14:20:29 +01:00
parent 12f8f80eb1
commit 86b05b902a
84 changed files with 4046 additions and 1055 deletions
+10 -12
View File
@@ -20,8 +20,11 @@ class GithubAppPolicy
*/
public function view(User $user, GithubApp $githubApp): bool
{
// return $user->teams->contains('id', $githubApp->team_id) || $githubApp->is_system_wide;
return true;
if ($githubApp->is_system_wide) {
return true;
}
return $user->teams->contains('id', $githubApp->team_id);
}
/**
@@ -29,8 +32,7 @@ class GithubAppPolicy
*/
public function create(User $user): bool
{
// return $user->isAdmin();
return true;
return $user->isAdmin();
}
/**
@@ -39,12 +41,10 @@ class GithubAppPolicy
public function update(User $user, GithubApp $githubApp): bool
{
if ($githubApp->is_system_wide) {
// return $user->isAdmin();
return true;
return $user->canAccessSystemResources();
}
// return $user->isAdmin() && $user->teams->contains('id', $githubApp->team_id);
return true;
return $user->isAdminOfTeam($githubApp->team_id);
}
/**
@@ -53,12 +53,10 @@ class GithubAppPolicy
public function delete(User $user, GithubApp $githubApp): bool
{
if ($githubApp->is_system_wide) {
// return $user->isAdmin();
return true;
return $user->canAccessSystemResources();
}
// return $user->isAdmin() && $user->teams->contains('id', $githubApp->team_id);
return true;
return $user->isAdminOfTeam($githubApp->team_id);
}
/**