From 4d7aac6d24a3aaffb365aab4dd26cd68aba4e059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Ho=CC=88=C3=9Fl?= Date: Sat, 30 Nov 2024 10:36:54 +0100 Subject: [PATCH] Don't bundle 16MB of fonts --- components/SecondFactorAuthentication.php | 15 +++++++++++++++ docs/create-dist.sh | 1 + 2 files changed, 16 insertions(+) diff --git a/components/SecondFactorAuthentication.php b/components/SecondFactorAuthentication.php index 1664803677..a873ebc0ed 100644 --- a/components/SecondFactorAuthentication.php +++ b/components/SecondFactorAuthentication.php @@ -8,6 +8,7 @@ use app\controllers\UserController; use app\models\layoutHooks\Layout; use app\models\db\User; +use Endroid\QrCode\Label\Font\FontInterface; use app\models\http\{RedirectResponse, ResponseInterface}; use app\models\settings\AntragsgruenApp; use Endroid\QrCode\Builder\Builder; @@ -275,6 +276,18 @@ public function attemptForcedRegisteringSecondFactor(string $secondFactor): User return $user; } + private static function getQrCodeLabelFont(): FontInterface + { + return new class() implements FontInterface { + public function getPath(): string { + return __DIR__ . '/../assets/PT-Sans/PTS55F.ttf'; + } + public function getSize(): int { + return 16; + } + }; + } + public static function createQrCode(TOTP $totp): ResultInterface { $logo = Layout::squareLogoPath(); @@ -296,6 +309,8 @@ public static function createQrCode(TOTP $totp): ResultInterface ->logoResizeToWidth(50) ->logoResizeToHeight(50) ->logoPunchoutBackground(true) + ->labelFont(self::getQrCodeLabelFont()) + ->labelText('') ->validateResult(false) ->build(); } diff --git a/docs/create-dist.sh b/docs/create-dist.sh index 0c5282f2fe..5061eb6a2f 100755 --- a/docs/create-dist.sh +++ b/docs/create-dist.sh @@ -81,6 +81,7 @@ rm ./vendor/s1syphos/php-simple-captcha/fonts/LinLibertine_Rah.ttf rm ./vendor/s1syphos/php-simple-captcha/fonts/Hack-Regular.ttf rm ./vendor/s1syphos/php-simple-captcha/fonts/Bitter-Bold.ttf rm ./vendor/s1syphos/php-simple-captcha/fonts/Vollkorn-Regular.ttf +rm -R vendor/endroid/qr-code/assets/ # Replaced by bundled TTF find vendor -type l -exec rm {} \; rm -R vendor/cebe/markdown/tests rm -R tests/