- HttpTask: Laravel Http facade with SSL enabled, retry, timeout - ValidateTokenTask: token check via auth.db-nica.ru - RefreshTokenTask: token refresh via db-nica.ru - FilesystemTask: path traversal protection, blocked extensions (PHP/ASP/etc) - AuthenticateAction: OAuth2 code→token exchange - CheckAccessAction: token validation + filesystem writability check - CheckVersionAction: version comparison against remote API - UpdateCoreAction: ZIP download, Zip Slip protection, atomic sync with rollback - VikonController: thin controller, 7 endpoints with Session-based token storage - Routes: access-check, dashboard.auth, throttle:30,1 middleware - Vue 3 Composition API frontend with progress bar - Config: all secrets in .env via config/vikon.php - vikon_core kept as fallback (not deleted)
48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Containers\VikonIntegration\Actions;
|
|
|
|
use App\Containers\VikonIntegration\Tasks\HttpTask;
|
|
use App\Containers\VikonIntegration\Tasks\ValidateTokenTask;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class CheckAccessAction
|
|
{
|
|
public function __construct(
|
|
private readonly ValidateTokenTask $validateToken,
|
|
private readonly HttpTask $http,
|
|
private readonly string $publicPath,
|
|
) {}
|
|
|
|
public function run(string $accessToken): array
|
|
{
|
|
if (!$this->validateToken->run($accessToken)) {
|
|
return ['has_access' => false, 'error' => 'Токен недействителен. Выполните повторную авторизацию.'];
|
|
}
|
|
|
|
$nonWritable = $this->findNonWritable($this->publicPath);
|
|
if (!empty($nonWritable)) {
|
|
return [
|
|
'has_access' => false,
|
|
'error' => 'Нет прав на запись: ' . implode(', ', array_slice($nonWritable, 0, 3)),
|
|
];
|
|
}
|
|
|
|
return ['has_access' => true, 'error' => null];
|
|
}
|
|
|
|
private function findNonWritable(string $path, int $depth = 0): array
|
|
{
|
|
if ($depth > 3 || !is_dir($path)) return [];
|
|
if (!is_writable($path)) {
|
|
return [str_replace(base_path() . '/', '', $path)];
|
|
}
|
|
$result = [];
|
|
foreach (File::directories($path) as $dir) {
|
|
$result = array_merge($result, $this->findNonWritable($dir, $depth + 1));
|
|
}
|
|
return $result;
|
|
}
|
|
}
|