Skip to content

Commit ccae7d9

Browse files
Remove unused /api/authtokens/all endpoint (#3626)
1 parent 5ac804b commit ccae7d9

4 files changed

Lines changed: 0 additions & 41 deletions

File tree

app/Http/Controllers/AuthTokenController.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,6 @@ public function manage(): View
2020
return $this->vue('manage-auth-tokens', 'Authentication Tokens');
2121
}
2222

23-
/**
24-
* Get all of the authentication tokens available across the entire system.
25-
* This method is only available to administrators.
26-
*/
27-
public function fetchAll(): JsonResponse
28-
{
29-
$token_array = AuthTokenUtil::getAllTokens();
30-
$token_map = [];
31-
foreach ($token_array as $token) {
32-
$token_map[$token['hash']] = $token;
33-
}
34-
35-
return response()->json([
36-
'tokens' => $token_map,
37-
]);
38-
}
39-
4023
public function createToken(Request $request): JsonResponse
4124
{
4225
$fields = ['scope', 'description'];

app/Utils/AuthTokenUtil.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use App\Models\User;
99
use CDash\Model\Project;
1010
use Illuminate\Auth\AuthenticationException;
11-
use Illuminate\Database\Eloquent\Collection;
1211
use Illuminate\Support\Carbon;
1312
use Illuminate\Support\Facades\Auth;
1413
use Illuminate\Support\Facades\Config;
@@ -210,21 +209,6 @@ public static function deleteToken(string $token_hash, int $expected_user_id): b
210209
return $auth_token->delete() > 0;
211210
}
212211

213-
/**
214-
* Contract: we assume that the user has already been validated and blindly return a list of
215-
* all auth tokens. It is your responsibility as a user of this method to ensure that only
216-
* administrators can access it.
217-
*
218-
* @return Collection<int,AuthToken>
219-
*/
220-
public static function getAllTokens(): Collection
221-
{
222-
return AuthToken::select('authtoken.*', 'project.name AS projectname', 'users.firstname AS owner_firstname', 'users.lastname AS owner_lastname')
223-
->leftJoin('project', 'project.id', '=', 'authtoken.projectid')
224-
->leftJoin('users', 'users.id', '=', 'authtoken.userid')
225-
->get();
226-
}
227-
228212
public static function hashToken(?string $unhashed_token): string
229213
{
230214
if ($unhashed_token === null || $unhashed_token === '') {

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -630,12 +630,6 @@ parameters:
630630
count: 1
631631
path: app/Http/Controllers/AuthTokenController.php
632632

633-
-
634-
rawMessage: Possibly invalid array key type mixed.
635-
identifier: offsetAccess.invalidOffset
636-
count: 1
637-
path: app/Http/Controllers/AuthTokenController.php
638-
639633
-
640634
rawMessage: 'Argument of an invalid type array|false supplied for foreach, only iterables are supported.'
641635
identifier: foreach.nonIterable

routes/api.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@
7070
Route::match(['get', 'post'], '/v1/manageOverview.php', 'ProjectOverviewController@apiManageOverview');
7171

7272
Route::middleware(['admin'])->group(function (): void {
73-
Route::get('/authtokens/all', 'AuthTokenController@fetchAll');
74-
7573
Route::get('/monitor', 'MonitorController@get');
7674
});
7775
});

0 commit comments

Comments
 (0)