This commit is contained in:
hashbro
2026-08-09 02:08:42 +08:00
parent 74a67c3900
commit 5c7600744e
24 changed files with 1510 additions and 70 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\Services;
use App\Models\Admin;
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
use PragmaRX\Google2FA\Google2FA;
class AdminGoogle2fa
{
private readonly Google2FA $google2fa;
public function __construct(?Google2FA $google2fa = null)
{
$this->google2fa = $google2fa ?? new Google2FA;
}
public function generateSecret(): string
{
return $this->google2fa->generateSecretKey();
}
public function verify(string $secret, string $code): bool
{
$code = trim($code);
if ($secret === '' || $code === '') {
return false;
}
return (bool) $this->google2fa->verifyKey($secret, $code);
}
public function otpAuthUrl(Admin $admin, string $secret): string
{
$issuer = (string) config('app.name', 'Coruna Lab');
return $this->google2fa->getQRCodeUrl($issuer, $admin->username.'@admin', $secret);
}
public function qrSvg(string $otpAuthUrl, int $size = 200): string
{
$writer = new Writer(new ImageRenderer(
new RendererStyle($size),
new SvgImageBackEnd
));
return $writer->writeString($otpAuthUrl);
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ class ChannelProjectService
throw new RuntimeException('投放域名未配置(CORUNA_LAB_CHANNEL_DOMAINS 或渠道 domains)');
}
if ($reportingDomains === []) {
throw new RuntimeException('上报域名未配置(CORUNA_LAB_AMIDN_DOMAINS)');
throw new RuntimeException('上报域名未配置(CORUNA_REPORTING_DOMAINS)');
}
$response = $this->request('post', $channelId, [
+1 -1
View File
@@ -83,7 +83,7 @@ class SettingsService
if (array_key_exists('channels.domains', $map) && $map['channels.domains'] !== null) {
$domains = self::parseDomains($map['channels.domains']);
// Settings override channel/deployment hosts only; reporting stays CORUNA_LAB_AMIDN_DOMAINS.
// Settings override channel hosts only; reporting stays CORUNA_REPORTING_DOMAINS.
config([
'coruna.channel_domains' => $domains,
'coruna.deployment_domains' => $domains,