Skip to content

Commit e4bbc7b

Browse files
krlmrrKarl MurrayOrrison
authored
[ADVAPP-1848]: Correct authorization to project users based on define project access (#1981)
* [ADVAPP-1848]: Update / Create models and migrations * Update code formatting and copyright headers * [ADVAPP-1848]: Add relation managers * Update code formatting and copyright headers * [ADVAPP-1848]: Add pages * [ADVAPP-1848]: Update ProjectPolicy * [ADVAPP-1848]: Remove Filament Changes * [ADVAPP-1848]: Fix missing import * [ADVAPP-1848]: Add Feature * Update code formatting and copyright headers * [ADVAPP-1848]: Add scope * Update code formatting and copyright headers * [ADVAPP-1848]: Add scope to project model * [ADVAPP-1848]: Fix liniting issue. * [ADVAPP-1848]: Add an early return * [ADVAPP-1848]: Cleanup the ProjectPolicy * [ADVAPP-1848]: Fix grammer * [ADVAPP-1848]: Add Relation Managers * Update code formatting and copyright headers * [ADVAPP-1848]: Get everything working * [ADVAPP-1848]: Get a suite of unit tests * [ADVAPP-1848]: Update Unit tests * [ADVAPP-1848]: Add a comment to update the file * [ADVAPP-1848]: Remove comment * [ADVAPP-1848]: Fix broken tests * [ADVAPP-1848]: Move attribute below the docblock * [ADVAPP-1848]: Fix the failing test * [ADVAPP-1848]: Get the next test passing * [ADVAPP-1848]: Remove the only * [ADVAPP-1848]: Revert the project observer * [ADVAPP-1848]: Update tests * [ADVAPP-1848]: Update the observer * [ADVAPP-1848]: Update the observer * [ADVAPP-1848]: Update the test * [ADVAPP-1848]: Update the policy * [ADVAPP-1848]: Fix unit tests * [ADVAPP-1848]: Fix unit tests * [ADVAPP-1848]: Comment out observer * [ADVAPP-1848]: Fix observer? * [ADVAPP-1848]: Unguard non-fillable properties in factory * [ADVAPP-1848]: Remove the only * [ADVAPP-1848]: Fix liniting issue * [ADVAPP-1848]: Remove observer * [ADVAPP-1848]: Add the Observer back * Update code formatting and copyright headers * [ADVAPP-1848]: Update a test that fails * [ADVAPP-1848]: Update a failing test * [ADVAPP-1848]: Update a failing test * [ADVAPP-1848]: Update a failing test * [ADVAPP-1848]: Update a failing test * [ADVAPP-1848]: Update failing tests * [ADVAPP-1848]: Update failing tests * [ADVAPP-1848]: Update failing tests * [ADVAPP-1848]: Update failing tests * [ADVAPP-1848]: Fix linting issue * [ADVAPP-1848]: Fix linting issue * [ADVAPP-1848]: Fix unit tests revert factory * [ADVAPP-1848]: Fix unit test * Ignore the specific phpstan error we don't want Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com> --------- Signed-off-by: Kevin Ullyott <kevin.ullyott@canyongbs.com> Co-authored-by: Karl Murray <karl.murray@canyongbs.com> Co-authored-by: Kevin Ullyott <kevin.ullyott@canyongbs.com>
1 parent 3817371 commit e4bbc7b

30 files changed

Lines changed: 1423 additions & 7 deletions

app-modules/project/database/factories/ProjectFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
class ProjectFactory extends Factory
4646
{
4747
/**
48-
*
4948
* @return array<string, mixed>
5049
*/
5150
public function definition(): array
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/*
4+
<COPYRIGHT>
5+
6+
Copyright © 2016-2025, Canyon GBS LLC. All rights reserved.
7+
8+
Advising App™ is licensed under the Elastic License 2.0. For more details,
9+
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
10+
11+
Notice:
12+
13+
- You may not provide the software to third parties as a hosted or managed
14+
service, where the service provides users with access to any substantial set of
15+
the features or functionality of the software.
16+
- You may not move, change, disable, or circumvent the license key functionality
17+
in the software, and you may not remove or obscure any functionality in the
18+
software that is protected by the license key.
19+
- You may not alter, remove, or obscure any licensing, copyright, or other notices
20+
of the licensor in the software. Any use of the licensor’s trademarks is subject
21+
to applicable law.
22+
- Canyon GBS LLC respects the intellectual property rights of others and expects the
23+
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
24+
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
25+
vigorously.
26+
- The software solution, including services, infrastructure, and code, is offered as a
27+
Software as a Service (SaaS) by Canyon GBS LLC.
28+
- Use of this software implies agreement to the license terms and conditions as stated
29+
in the Elastic License 2.0.
30+
31+
For more information or inquiries please visit our website at
32+
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.
33+
34+
</COPYRIGHT>
35+
*/
36+
37+
use Illuminate\Database\Migrations\Migration;
38+
use Tpetry\PostgresqlEnhanced\Schema\Blueprint;
39+
use Tpetry\PostgresqlEnhanced\Support\Facades\Schema;
40+
41+
return new class () extends Migration {
42+
public function up(): void
43+
{
44+
Schema::create('project_manager_users', function (Blueprint $table) {
45+
$table->uuid('id')->primary();
46+
$table->foreignUuid('project_id')->constrained()->cascadeOnDelete();
47+
$table->foreignUuid('user_id')->constrained()->cascadeOnDelete();
48+
$table->timestamps();
49+
});
50+
}
51+
52+
public function down(): void
53+
{
54+
Schema::dropIfExists('project_manager_users');
55+
}
56+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/*
4+
<COPYRIGHT>
5+
6+
Copyright © 2016-2025, Canyon GBS LLC. All rights reserved.
7+
8+
Advising App™ is licensed under the Elastic License 2.0. For more details,
9+
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
10+
11+
Notice:
12+
13+
- You may not provide the software to third parties as a hosted or managed
14+
service, where the service provides users with access to any substantial set of
15+
the features or functionality of the software.
16+
- You may not move, change, disable, or circumvent the license key functionality
17+
in the software, and you may not remove or obscure any functionality in the
18+
software that is protected by the license key.
19+
- You may not alter, remove, or obscure any licensing, copyright, or other notices
20+
of the licensor in the software. Any use of the licensor’s trademarks is subject
21+
to applicable law.
22+
- Canyon GBS LLC respects the intellectual property rights of others and expects the
23+
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
24+
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
25+
vigorously.
26+
- The software solution, including services, infrastructure, and code, is offered as a
27+
Software as a Service (SaaS) by Canyon GBS LLC.
28+
- Use of this software implies agreement to the license terms and conditions as stated
29+
in the Elastic License 2.0.
30+
31+
For more information or inquiries please visit our website at
32+
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.
33+
34+
</COPYRIGHT>
35+
*/
36+
37+
use Illuminate\Database\Migrations\Migration;
38+
use Tpetry\PostgresqlEnhanced\Schema\Blueprint;
39+
use Tpetry\PostgresqlEnhanced\Support\Facades\Schema;
40+
41+
return new class () extends Migration {
42+
public function up(): void
43+
{
44+
Schema::create('project_manager_teams', function (Blueprint $table) {
45+
$table->uuid('id')->primary();
46+
$table->foreignUuid('project_id')->constrained()->cascadeOnDelete();
47+
$table->foreignUuid('team_id')->constrained()->cascadeOnDelete();
48+
$table->timestamps();
49+
});
50+
}
51+
52+
public function down(): void
53+
{
54+
Schema::dropIfExists('project_manager_teams');
55+
}
56+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/*
4+
<COPYRIGHT>
5+
6+
Copyright © 2016-2025, Canyon GBS LLC. All rights reserved.
7+
8+
Advising App™ is licensed under the Elastic License 2.0. For more details,
9+
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
10+
11+
Notice:
12+
13+
- You may not provide the software to third parties as a hosted or managed
14+
service, where the service provides users with access to any substantial set of
15+
the features or functionality of the software.
16+
- You may not move, change, disable, or circumvent the license key functionality
17+
in the software, and you may not remove or obscure any functionality in the
18+
software that is protected by the license key.
19+
- You may not alter, remove, or obscure any licensing, copyright, or other notices
20+
of the licensor in the software. Any use of the licensor’s trademarks is subject
21+
to applicable law.
22+
- Canyon GBS LLC respects the intellectual property rights of others and expects the
23+
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
24+
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
25+
vigorously.
26+
- The software solution, including services, infrastructure, and code, is offered as a
27+
Software as a Service (SaaS) by Canyon GBS LLC.
28+
- Use of this software implies agreement to the license terms and conditions as stated
29+
in the Elastic License 2.0.
30+
31+
For more information or inquiries please visit our website at
32+
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.
33+
34+
</COPYRIGHT>
35+
*/
36+
37+
use Illuminate\Database\Migrations\Migration;
38+
use Tpetry\PostgresqlEnhanced\Schema\Blueprint;
39+
use Tpetry\PostgresqlEnhanced\Support\Facades\Schema;
40+
41+
return new class () extends Migration {
42+
public function up(): void
43+
{
44+
Schema::create('project_auditor_users', function (Blueprint $table) {
45+
$table->uuid('id')->primary();
46+
$table->foreignUuid('project_id')->constrained()->cascadeOnDelete();
47+
$table->foreignUuid('user_id')->constrained()->cascadeOnDelete();
48+
$table->timestamps();
49+
});
50+
}
51+
52+
public function down(): void
53+
{
54+
Schema::dropIfExists('project_auditor_users');
55+
}
56+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/*
4+
<COPYRIGHT>
5+
6+
Copyright © 2016-2025, Canyon GBS LLC. All rights reserved.
7+
8+
Advising App™ is licensed under the Elastic License 2.0. For more details,
9+
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
10+
11+
Notice:
12+
13+
- You may not provide the software to third parties as a hosted or managed
14+
service, where the service provides users with access to any substantial set of
15+
the features or functionality of the software.
16+
- You may not move, change, disable, or circumvent the license key functionality
17+
in the software, and you may not remove or obscure any functionality in the
18+
software that is protected by the license key.
19+
- You may not alter, remove, or obscure any licensing, copyright, or other notices
20+
of the licensor in the software. Any use of the licensor’s trademarks is subject
21+
to applicable law.
22+
- Canyon GBS LLC respects the intellectual property rights of others and expects the
23+
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
24+
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
25+
vigorously.
26+
- The software solution, including services, infrastructure, and code, is offered as a
27+
Software as a Service (SaaS) by Canyon GBS LLC.
28+
- Use of this software implies agreement to the license terms and conditions as stated
29+
in the Elastic License 2.0.
30+
31+
For more information or inquiries please visit our website at
32+
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.
33+
34+
</COPYRIGHT>
35+
*/
36+
37+
use Illuminate\Database\Migrations\Migration;
38+
use Tpetry\PostgresqlEnhanced\Schema\Blueprint;
39+
use Tpetry\PostgresqlEnhanced\Support\Facades\Schema;
40+
41+
return new class () extends Migration {
42+
public function up(): void
43+
{
44+
Schema::create('project_auditor_teams', function (Blueprint $table) {
45+
$table->uuid('id')->primary();
46+
$table->foreignUuid('project_id')->constrained()->cascadeOnDelete();
47+
$table->foreignUuid('team_id')->constrained()->cascadeOnDelete();
48+
$table->timestamps();
49+
});
50+
}
51+
52+
public function down(): void
53+
{
54+
Schema::dropIfExists('project_auditor_teams');
55+
}
56+
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
/*
4+
<COPYRIGHT>
5+
6+
Copyright © 2016-2025, Canyon GBS LLC. All rights reserved.
7+
8+
Advising App™ is licensed under the Elastic License 2.0. For more details,
9+
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
10+
11+
Notice:
12+
13+
- You may not provide the software to third parties as a hosted or managed
14+
service, where the service provides users with access to any substantial set of
15+
the features or functionality of the software.
16+
- You may not move, change, disable, or circumvent the license key functionality
17+
in the software, and you may not remove or obscure any functionality in the
18+
software that is protected by the license key.
19+
- You may not alter, remove, or obscure any licensing, copyright, or other notices
20+
of the licensor in the software. Any use of the licensor’s trademarks is subject
21+
to applicable law.
22+
- Canyon GBS LLC respects the intellectual property rights of others and expects the
23+
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
24+
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
25+
vigorously.
26+
- The software solution, including services, infrastructure, and code, is offered as a
27+
Software as a Service (SaaS) by Canyon GBS LLC.
28+
- Use of this software implies agreement to the license terms and conditions as stated
29+
in the Elastic License 2.0.
30+
31+
For more information or inquiries please visit our website at
32+
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.
33+
34+
</COPYRIGHT>
35+
*/
36+
37+
namespace AdvisingApp\Project\Filament\Resources\Projects\Pages;
38+
39+
use AdvisingApp\Project\Filament\Resources\Projects\ProjectResource;
40+
use AdvisingApp\Project\Filament\Resources\Projects\RelationManagers\AuditorTeamsRelationManager;
41+
use AdvisingApp\Project\Filament\Resources\Projects\RelationManagers\AuditorUsersRelationManager;
42+
use Filament\Resources\Pages\ManageRelatedRecords;
43+
44+
class ManageAuditors extends ManageRelatedRecords
45+
{
46+
protected static string $resource = ProjectResource::class;
47+
48+
protected static string $relationship = 'auditorUsers';
49+
50+
public static function getNavigationLabel(): string
51+
{
52+
return 'Auditors';
53+
}
54+
55+
public function getRelationManagers(): array
56+
{
57+
return [
58+
AuditorUsersRelationManager::class,
59+
AuditorTeamsRelationManager::class,
60+
];
61+
}
62+
63+
public static function canAccess(array $arguments = []): bool
64+
{
65+
$user = auth()->user();
66+
67+
return $user->can(['project.view-any', 'project.*.view']) && parent::canAccess($arguments);
68+
}
69+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
/*
4+
<COPYRIGHT>
5+
6+
Copyright © 2016-2025, Canyon GBS LLC. All rights reserved.
7+
8+
Advising App™ is licensed under the Elastic License 2.0. For more details,
9+
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.
10+
11+
Notice:
12+
13+
- You may not provide the software to third parties as a hosted or managed
14+
service, where the service provides users with access to any substantial set of
15+
the features or functionality of the software.
16+
- You may not move, change, disable, or circumvent the license key functionality
17+
in the software, and you may not remove or obscure any functionality in the
18+
software that is protected by the license key.
19+
- You may not alter, remove, or obscure any licensing, copyright, or other notices
20+
of the licensor in the software. Any use of the licensor’s trademarks is subject
21+
to applicable law.
22+
- Canyon GBS LLC respects the intellectual property rights of others and expects the
23+
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
24+
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
25+
vigorously.
26+
- The software solution, including services, infrastructure, and code, is offered as a
27+
Software as a Service (SaaS) by Canyon GBS LLC.
28+
- Use of this software implies agreement to the license terms and conditions as stated
29+
in the Elastic License 2.0.
30+
31+
For more information or inquiries please visit our website at
32+
https://www.canyongbs.com or contact us via email at legal@canyongbs.com.
33+
34+
</COPYRIGHT>
35+
*/
36+
37+
namespace AdvisingApp\Project\Filament\Resources\Projects\Pages;
38+
39+
use AdvisingApp\Project\Filament\Resources\Projects\ProjectResource;
40+
use AdvisingApp\Project\Filament\Resources\Projects\RelationManagers\ManagerTeamsRelationManager;
41+
use AdvisingApp\Project\Filament\Resources\Projects\RelationManagers\ManagerUsersRelationManager;
42+
use Filament\Resources\Pages\ManageRelatedRecords;
43+
44+
class ManageManagers extends ManageRelatedRecords
45+
{
46+
protected static string $resource = ProjectResource::class;
47+
48+
protected static string $relationship = 'managerUsers';
49+
50+
public static function getNavigationLabel(): string
51+
{
52+
return 'Managers';
53+
}
54+
55+
public function getRelationManagers(): array
56+
{
57+
return [
58+
ManagerUsersRelationManager::class,
59+
ManagerTeamsRelationManager::class,
60+
];
61+
}
62+
63+
public static function canAccess(array $arguments = []): bool
64+
{
65+
$user = auth()->user();
66+
67+
return $user->can(['project.view-any', 'project.*.view']) && parent::canAccess($arguments);
68+
}
69+
}

0 commit comments

Comments
 (0)