이슈 본연: API 레퍼런스의 미채움 마커 5종(실측 제외/TODO/필드 없음/대표 에러 없음)
1,194건을 코드에서 읽어 전수 채우고(0건), api:docgen 재생성이 사람이 채운 내용을
손실·열화시키던 멱등성 결함 4종(CRLF, 표 파이프 이스케이프, 에러 서술 보존, 중복
라우트명 키)을 근본 수정. --check 를 실측 제외와 드리프트가 구분되도록 재정의.
ParameterDescriber/ResourceFieldDescriber 에 leaf 폴백·SEO 스코프·공통 사전 확장.
파생 결함(문서 실측 중 발견): ResponseHelper 기본 메시지 키 6종이 존재하지 않는
messages.* 를 가리켜 응답 message 가 번역문 대신 키 문자열로 노출되던 문제를 common.*
으로 정정하고, 코어 7 + gdpr/marketing/pay_kginicis/verification/ecommerce 확장의
호출부와 누락 lang 키(게시판 10키 + 이커머스 category_images 4키 포함)를 ko/en/ja
전수 정정. 중복 그룹 키 2건은 기존 키로 호출부 통합.
보안: GET /api/identity/challenges/{id} 는 권한 가드 없는 공개 폴링 엔드포인트인데
Service::getStatus 가 attempts/max_attempts 를 응답에 담아 남은 시도 횟수를 추론할 수
있었다. 두 필드를 제거하고, 챌린지 화면(admin_basic/basic)의 서버 attempts 참조를
제거(남은 횟수 UI 는 query fallback + verify 실패 시 로컬 증가로 유지).
부수 정리(변경셋에 들어온 board 컨트롤러의 audit 사전 결함): FormRequest 4개 신설로
base Request 주입 제거, CommentController 의 Board 직접 호출을 BoardService 위임으로
전환, PHPDoc @return 보강. board 스위트에서 발견한 stale test 3건(seed SSoT 불일치,
admin 계정 user 역할 누락)도 같은 세션에서 정정.
버전 정렬(공개 release 기준): 코어 7.0.3→7.0.4, sirsoft-board 1.0.1→1.0.2,
verification_kginicis 1.0.0→1.0.1, admin_basic 1.0.1→1.0.4.
115 lines
4.1 KiB
PHP
115 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Admin;
|
|
|
|
use App\Extension\PluginManager;
|
|
use App\Http\Controllers\Api\Base\AdminBaseController;
|
|
use App\Http\Requests\Admin\UpdatePluginSettingsRequest;
|
|
use App\Services\PluginSettingsService;
|
|
use App\Support\SensitiveSettingMask;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
/**
|
|
* 플러그인 설정 API 컨트롤러
|
|
*
|
|
* 플러그인의 설정 조회, 수정, 레이아웃 조회 기능을 제공합니다.
|
|
*/
|
|
class PluginSettingsController extends AdminBaseController
|
|
{
|
|
/**
|
|
* PluginSettingsController 생성자
|
|
*
|
|
* @param PluginSettingsService $pluginSettingsService 플러그인 설정 서비스
|
|
* @param PluginManager $pluginManager 설정 스키마(sensitive 플래그) 조회용
|
|
*/
|
|
public function __construct(
|
|
private PluginSettingsService $pluginSettingsService,
|
|
private PluginManager $pluginManager
|
|
) {
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* 응답에 실을 설정에서 민감값을 마스크로 치환한다.
|
|
*
|
|
* 이 응답은 관리자 화면으로 나가므로 암호화 키·시크릿의 평문이 브라우저·개발자 도구·프록시
|
|
* 로그에 남지 않아야 한다. 값이 저장되어 있다는 사실만 마스크로 알린다. 운영자가 값을 건드리지
|
|
* 않으면 화면이 마스크를 그대로 되돌려 보내고, 저장 단계가 그것을 걸러 기존 값을 보존한다.
|
|
*
|
|
* @param string $identifier 플러그인 식별자
|
|
* @param array<string, mixed> $settings 복호화된 설정
|
|
* @return array<string, mixed> 마스킹된 설정
|
|
*/
|
|
private function maskSensitive(string $identifier, array $settings): array
|
|
{
|
|
$plugin = $this->pluginManager->getPlugin($identifier);
|
|
|
|
return $plugin === null
|
|
? $settings
|
|
: SensitiveSettingMask::apply($settings, $plugin->getSettingsSchema());
|
|
}
|
|
|
|
/**
|
|
* 플러그인 설정을 조회합니다.
|
|
*
|
|
* @param string $identifier 플러그인 식별자
|
|
* @return JsonResponse 설정 데이터
|
|
*/
|
|
public function show(string $identifier): JsonResponse
|
|
{
|
|
$settings = $this->pluginSettingsService->get($identifier);
|
|
|
|
if ($settings === null) {
|
|
return $this->notFound('plugins.not_found');
|
|
}
|
|
|
|
return $this->success('common.success', $this->maskSensitive($identifier, $settings));
|
|
}
|
|
|
|
/**
|
|
* 플러그인 설정을 업데이트합니다.
|
|
*
|
|
* @param UpdatePluginSettingsRequest $request 검증된 요청
|
|
* @param string $identifier 플러그인 식별자
|
|
* @return JsonResponse 업데이트 결과
|
|
*/
|
|
public function update(UpdatePluginSettingsRequest $request, string $identifier): JsonResponse
|
|
{
|
|
// 검증을 통과한 필드만 저장한다. 과거에는 validated() 가 비면 all() 로 폴백했으나,
|
|
// 그 명분이던 "PluginManager 미등록 플러그인" 은 PluginSettingsService::save() 가
|
|
// 이미 false 로 차단하므로 도달할 수 없었고, 실제로는 설정 스키마 밖의 키가
|
|
// 그대로 설정 파일에 병합되는 경로로만 동작했다 (mass-assignment).
|
|
$settings = $request->validated();
|
|
|
|
$result = $this->pluginSettingsService->save($identifier, $settings);
|
|
|
|
if (! $result) {
|
|
return $this->error('plugins.settings.update_failed', 500);
|
|
}
|
|
|
|
return $this->success(
|
|
'plugins.settings.updated',
|
|
$this->maskSensitive($identifier, $this->pluginSettingsService->get($identifier) ?? [])
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 플러그인 설정 레이아웃을 조회합니다.
|
|
*
|
|
* 설정 페이지 UI 구성과 설정 스키마를 반환합니다.
|
|
*
|
|
* @param string $identifier 플러그인 식별자
|
|
* @return JsonResponse 레이아웃 데이터
|
|
*/
|
|
public function layout(string $identifier): JsonResponse
|
|
{
|
|
$layout = $this->pluginSettingsService->getLayout($identifier);
|
|
|
|
if ($layout === null) {
|
|
return $this->notFound('plugins.not_found');
|
|
}
|
|
|
|
return $this->success('common.success', $layout);
|
|
}
|
|
}
|