- 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)
37 lines
1021 B
PHP
37 lines
1021 B
PHP
<?php
|
|
|
|
namespace App\Containers\VikonIntegration\Tasks;
|
|
|
|
class RefreshTokenTask
|
|
{
|
|
public function __construct(
|
|
private readonly HttpTask $http,
|
|
private readonly string $clientId,
|
|
private readonly string $clientSecret,
|
|
) {}
|
|
|
|
/**
|
|
* @return array{access_token: string, refresh_token: string}
|
|
*/
|
|
public function run(string $refreshToken): array
|
|
{
|
|
$response = $this->http->post('oauth2/RefreshToken', [
|
|
'refresh_token' => $refreshToken,
|
|
'client_id' => $this->clientId,
|
|
'client_secret' => $this->clientSecret,
|
|
'grant_type' => 'refresh_token',
|
|
]);
|
|
|
|
$body = $response->json();
|
|
|
|
if (!isset($body['access_token'], $body['refresh_token'])) {
|
|
throw new \RuntimeException('Token refresh failed: ' . ($body['message'] ?? 'Unknown'));
|
|
}
|
|
|
|
return [
|
|
'access_token' => $body['access_token'],
|
|
'refresh_token' => $body['refresh_token'],
|
|
];
|
|
}
|
|
}
|