Load site settings from dotenv and store OAuth credentials

This commit is contained in:
2026-11-23 16:53:29 +08:00
parent 1bb0554608
commit 01ede89dcd
27 changed files with 730 additions and 76 deletions
+3 -1
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace App\Http;
use App\Config\Environment;
final class Request extends \support\Request
{
private const LOOPBACK = ['127.0.0.1', '::1'];
@@ -21,7 +23,7 @@ final class Request extends \support\Request
private function fromTrustedProxy(): bool
{
$configured = getenv('LAYSITE_TRUSTED_PROXIES');
$configured = Environment::get('LAYSITE_TRUSTED_PROXIES');
$trusted = $configured === false ? self::LOOPBACK : array_map('trim', explode(',', $configured));
return in_array($this->getRemoteIp(), $trusted, true);
+2 -1
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Http;
use App\Config\Environment;
use support\Request;
use support\Response;
use Workerman\Protocols\Http\Session;
@@ -26,7 +27,7 @@ final class VisitorSession
public static function cookie(Response $response, ?Session $session, int $seconds): Response
{
return $response->cookie(self::COOKIE, $session?->getId() ?? '', $seconds, '/',
secure: getenv('LAYSITE_SECURE_COOKIES') === '1', httpOnly: true, sameSite: 'Lax');
secure: Environment::get('LAYSITE_SECURE_COOKIES') === '1', httpOnly: true, sameSite: 'Lax');
}
public static function profile(?Request $request): ?array