feat(core): DB 최고권한 계정 차단 + OPcache 상태 안내
설치 단계와 코어 부팅의 정책이 엇갈려 있었다. 인스톨러는 root 를 자유롭게 허용하면서, 설치 후 부팅은 같은 값을 보고 확장 로딩 전체를 조용히 스킵했다. 설치는 성공하지만 이후 깨진 화면만 뜨고 원인은 로그 한 줄에만 남았다. 판정을 프레임워크 의존성 0 인 공용 SSoT 로 모아 인스톨러와 코어가 같은 답을 내게 하고, 설치 단계에서 서버 2경로로 차단하며, 설치 후 변경은 전용 에러 페이지로 드러낸다. 가드를 boot 가 아닌 미들웨어에 두어 artisan 이 죽지 않게 해 복구 수단을 남겼다. admin 은 일반 권한 운영 계정 오차단을 막기 위해 차단 목록에서 제외했다. OPcache 는 상태 조회 경로 자체가 없어 성능 저하를 인지할 방법이 없었다. 설치 단계 경고(비차단)와 관리자 정보 탭 표시를 같은 판정 SSoT 로 추가했다. 확장 로드 여부만으로는 부족해 opcache.enable 지시자까지 확인하며, ini_get 이 차단된 환경은 "확인 불가"로 폴백해 경고도 차단도 하지 않는다.
This commit is contained in:
1 parent
91ec5f2d1f
commit
062a88ca04
38 files changed
+2402
-56
No files matched your search
@@ -92,6 +92,7 @@ use App\Services\DriverRegistryService;
|
||||
use App\Services\LayoutExtensionService;
|
||||
use App\Services\TemplateLayoutAttachmentService;
|
||||
use App\Services\UniqueIdService;
|
||||
use App\Support\PrivilegedDatabaseAccounts;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
@@ -338,9 +339,9 @@ class CoreServiceProvider extends ServiceProvider
|
||||
return;
|
||||
}
|
||||
|
||||
// DB 연결 유효성 검증 (root 사용자 접속 방지)
|
||||
// DB 연결 유효성 검증 (최고권한 계정 접속 방지)
|
||||
if (! $this->isDatabaseConnectionValid()) {
|
||||
Log::error('Database connection invalid: using root user or missing credentials. Skipping extension loading.');
|
||||
Log::error('Database connection invalid: using a privileged database account or missing credentials. Skipping extension loading.');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -444,30 +445,20 @@ class CoreServiceProvider extends ServiceProvider
|
||||
/**
|
||||
* 데이터베이스 연결이 유효한지 검증합니다.
|
||||
*
|
||||
* root 사용자로 접속하거나 비밀번호가 없는 경우를 감지하여
|
||||
* DB 최고권한 계정으로 접속하거나 사용자명이 비어 있는 경우를 감지하여
|
||||
* 잘못된 설정으로 인한 접속 오류를 방지합니다.
|
||||
* 계정 판정은 `PrivilegedDatabaseAccounts` 가 SSoT 입니다.
|
||||
*
|
||||
* @return bool 연결이 유효하면 true
|
||||
*/
|
||||
protected function isDatabaseConnectionValid(): bool
|
||||
{
|
||||
try {
|
||||
$config = DB::connection()->getConfig();
|
||||
// read/write 분리 설정의 우선순위 규칙까지 PrivilegedDatabaseAccounts 가 소유한다.
|
||||
// 호출처마다 규칙이 달라지면 같은 설정에 서로 다른 판정이 나온다.
|
||||
$username = PrivilegedDatabaseAccounts::resolveUsername(DB::connection()->getConfig());
|
||||
|
||||
// read/write 분리 설정인 경우 read 설정 확인
|
||||
$username = $config['username'] ?? null;
|
||||
|
||||
// read 설정이 배열로 있는 경우
|
||||
if (isset($config['read']['username'])) {
|
||||
$username = $config['read']['username'];
|
||||
}
|
||||
|
||||
// root 사용자 또는 빈 username인 경우 무효
|
||||
if (empty($username) || $username === 'root') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return PrivilegedDatabaseAccounts::isUsable($username);
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Database configuration check failed: '.$e->getMessage());
|
||||
|
||||
|
||||
Reference in new issue
Block a user