Deploy Ladill Link / deploy (push) Successful in 37s
Add Bitly-style branded domain support via Ladill Domains SSL API, account analytics dashboard, settings page with default domain picker, and fix SSO/dashboard issues from QR Plus template leftovers. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\CustomDomain\LinkCustomDomainService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class SslCallbackController extends Controller
|
|
{
|
|
public function __invoke(Request $request, LinkCustomDomainService $service): JsonResponse
|
|
{
|
|
$secret = (string) config('customdomain.callback_secret');
|
|
$body = $request->getContent();
|
|
$signature = (string) $request->header('X-Ladill-Signature', '');
|
|
|
|
if ($secret === '' || ! hash_equals(hash_hmac('sha256', $body, $secret), $signature)) {
|
|
return response()->json(['error' => 'Invalid signature.'], 401);
|
|
}
|
|
|
|
$payload = json_decode($body, true);
|
|
$data = (array) ($payload['data'] ?? []);
|
|
$host = (string) ($data['host'] ?? '');
|
|
if ($host === '') {
|
|
return response()->json(['error' => 'Missing host.'], 422);
|
|
}
|
|
|
|
$service->applyCallback(
|
|
$host,
|
|
(string) ($data['status'] ?? 'failed'),
|
|
$data['expires_at'] ?? null,
|
|
$data['last_error'] ?? null,
|
|
);
|
|
|
|
return response()->json(['status' => 'ok']);
|
|
}
|
|
}
|