v7.0.0 release

This commit is contained in:
HeuJung committed 2026-07-01 10:30:32 +09:00
1 parent 0e7fa04b03
commit c4ea9a6cd1
3582 files changed
+626189 -160151

No files matched your search

@@ -2,10 +2,11 @@
namespace App\Http\Requests\Admin\Identity;
use App\Contracts\Repositories\IdentityMessageDefinitionRepositoryInterface;
use App\Contracts\Repositories\IdentityPolicyRepositoryInterface;
use App\Extension\HookManager;
use App\Extension\IdentityVerification\IdentityVerificationManager;
use App\Models\IdentityMessageDefinition;
use App\Models\IdentityPolicy;
use App\Rules\LocaleRequiredTranslatable;
use App\Rules\TranslatableField;
use Closure;
@@ -100,9 +101,9 @@ class StoreIdentityMessageDefinitionRequest extends FormRequest
return;
}
$exists = IdentityPolicy::where('key', $value)
->where('source_type', 'admin')
->exists();
// Service-Repository 패턴: Model facade 직접 호출 금지 → Repository Interface 경유.
$exists = app(IdentityPolicyRepositoryInterface::class)
->existsByKeyAndSourceType($value, 'admin');
if (! $exists) {
$fail(__('validation.identity_message.scope_value_not_admin_policy'));
@@ -125,12 +126,11 @@ class StoreIdentityMessageDefinitionRequest extends FormRequest
return;
}
$exists = IdentityMessageDefinition::where('provider_id', $providerId)
->where('scope_type', $scopeType)
->where('scope_value', $value)
->exists();
// Service-Repository 패턴: Model facade 직접 호출 금지 → Repository Interface 경유.
$existing = app(IdentityMessageDefinitionRepositoryInterface::class)
->findByScope($providerId, $scopeType, $value);
if ($exists) {
if ($existing !== null) {
$fail(__('validation.identity_message.definition_already_exists'));
}
};
@@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests\Admin;
use App\Extension\HookManager;
use Illuminate\Foundation\Http\FormRequest;
/**
* 봇 HTML 미리보기 요청 검증.
*
* 편집기가 dirty 레이아웃 + 샘플 컨텍스트를 POST 로 보낸다. 권한 체크는 라우트
* `core.templates.layouts.edit` 미들웨어에서 수행한다(authorize() 는 true 고정).
*/
class SeoBotPreviewRequest extends FormRequest
{
/**
* 사용자가 이 요청을 수행할 권한이 있는지 확인합니다.
*
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
*
* @return bool 항상 true
*/
public function authorize(): bool
{
return true;
}
/**
* 요청에 적용할 검증 규칙을 반환합니다.
*
* @return array<string, array<int, string>> 검증 규칙 배열
*/
public function rules(): array
{
$rules = [
'layout' => ['required', 'array'],
'route_params' => ['nullable', 'array'],
'url' => ['nullable', 'string'],
'locale' => ['nullable', 'string'],
'module_id' => ['nullable', 'string'],
'plugin_id' => ['nullable', 'string'],
'seed_context' => ['nullable', 'array'],
];
return HookManager::applyFilters('core.seo_bot_preview.show_validation_rules', $rules, $this);
}
}
@@ -0,0 +1,43 @@
<?php
namespace App\Http\Requests\Admin;
use App\Extension\HookManager;
use Illuminate\Foundation\Http\FormRequest;
/**
* SEO 후보 조회 요청 검증.
*
* 편집기가 현재 레이아웃의 extensions·page_type 을 query 로 보낸다. 권한 체크는 라우트
* `core.templates.layouts.edit` 미들웨어에서 수행한다(authorize() 는 true 고정).
*/
class SeoCandidateRequest extends FormRequest
{
/**
* 사용자가 이 요청을 수행할 권한이 있는지 확인합니다.
*
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
*
* @return bool 항상 true
*/
public function authorize(): bool
{
return true;
}
/**
* 요청에 적용할 검증 규칙을 반환합니다.
*
* @return array<string, array<int, string>> 검증 규칙 배열
*/
public function rules(): array
{
$rules = [
// extensions 는 JSON 문자열 또는 배열 — 컨트롤러가 관대하게 파싱(가드는 미들웨어).
'extensions' => ['nullable'],
'page_type' => ['nullable', 'string'],
];
return HookManager::applyFilters('core.seo_candidate.index_validation_rules', $rules, $this);
}
}
@@ -0,0 +1,46 @@
<?php
namespace App\Http\Requests\Admin;
use App\Extension\HookManager;
use Illuminate\Foundation\Http\FormRequest;
/**
* OG/Twitter/구조화 미리보기 요청 검증.
*
* 편집기가 dirty meta.seo + 샘플 컨텍스트를 POST 로 보낸다. 권한 체크는 라우트
* `core.templates.layouts.edit` 미들웨어에서 수행한다(authorize() 는 true 고정).
*/
class SeoOgPreviewRequest extends FormRequest
{
/**
* 사용자가 이 요청을 수행할 권한이 있는지 확인합니다.
*
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
*
* @return bool 항상 true
*/
public function authorize(): bool
{
return true;
}
/**
* 요청에 적용할 검증 규칙을 반환합니다.
*
* @return array<string, array<int, string>> 검증 규칙 배열
*/
public function rules(): array
{
$rules = [
'seo' => ['required', 'array'],
// 이 레이아웃이 직접 선언한 meta.seo(base 병합 전). 병합본에는 있으나 own 에 없는
// og/twitter 키 = base 상속(SEO-B). 선택 — 미전달 시 상속/자체 구분 안 함.
'own_seo' => ['nullable', 'array'],
'seed_context' => ['nullable', 'array'],
'route_params' => ['nullable', 'array'],
];
return HookManager::applyFilters('core.seo_og_preview.show_validation_rules', $rules, $this);
}
}
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Requests\Admin\Template;
use App\Extension\HookManager;
use Illuminate\Foundation\Http\FormRequest;
/**
* 템플릿 레이아웃 첨부 파일 목록 조회 요청 검증
*
* 권한은 라우트의 permission 미들웨어(core.templates.layouts.edit)가 담당하므로
* authorize()는 true 를 고정 반환한다.
*/
class ListTemplateLayoutAttachmentsRequest extends FormRequest
{
/**
* 요청 권한 확인 — 권한은 permission 미들웨어가 담당.
*
* @return bool 항상 true
*/
public function authorize(): bool
{
return true;
}
/**
* 검증 규칙 — layout_name 쿼리 필터(선택).
*
* @return array<string, mixed>
*/
public function rules(): array
{
$rules = [
'layout_name' => ['nullable', 'string', 'max:150'],
];
// 모듈/플러그인이 검증 규칙을 동적으로 확장할 수 있도록 훅 제공
return HookManager::applyFilters('core.template_layout_attachment.list_validation_rules', $rules, $this);
}
}
@@ -0,0 +1,63 @@
<?php
namespace App\Http\Requests\Admin\Template;
use App\Extension\HookManager;
use Illuminate\Foundation\Http\FormRequest;
/**
* 템플릿 레이아웃 첨부 파일 업로드 요청 검증
*
* 권한 검사는 라우트의 permission 미들웨어(core.templates.layouts.edit)가 담당하므로
* authorize()는 true 를 고정 반환한다(FormRequest authorize 에 권한 로직 금지 규칙).
*/
class UploadTemplateLayoutAttachmentRequest extends FormRequest
{
/**
* 요청 권한 확인 — 권한은 permission 미들웨어가 담당.
*
* @return bool 항상 true
*/
public function authorize(): bool
{
return true;
}
/**
* 검증 규칙
*
* @return array<string, mixed>
*/
public function rules(): array
{
// 배경 이미지 등 — 이미지 파일만 허용. 최대 크기는 첨부 설정 재사용(MB→KB).
$maxSize = config('attachment.max_file_size', 10240);
$rules = [
'file' => ['required', 'file', 'image', 'mimes:jpg,jpeg,png,gif,webp,svg', 'max:'.$maxSize],
'layout_name' => ['nullable', 'string', 'max:150'],
];
// 모듈/플러그인이 검증 규칙을 동적으로 확장할 수 있도록 훅 제공
return HookManager::applyFilters('core.template_layout_attachment.upload_validation_rules', $rules, $this);
}
/**
* 검증 메시지
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'file.required' => __('templates.layout_attachments.validation.file_required'),
'file.file' => __('templates.layout_attachments.validation.file_invalid'),
'file.image' => __('templates.layout_attachments.validation.file_image'),
'file.mimes' => __('templates.layout_attachments.validation.file_mimes'),
'file.max' => __('templates.layout_attachments.validation.file_max', [
'max' => (int) (config('attachment.max_file_size', 10240) / 1024),
]),
'layout_name.max' => __('templates.layout_attachments.validation.layout_name_max'),
];
}
}
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Requests\Identity;
use App\Extension\HookManager;
use Illuminate\Foundation\Http\FormRequest;
/**
* 운영자가 IDV 정책을 삭제할 때의 요청 검증.
*
* 삭제 가능 여부(source_type='admin' 만 허용)는 Controller 가 도메인 규칙으로 판정하며,
* 인증/권한은 라우트의 permission 미들웨어 체인이 담당합니다. 이 FormRequest 는 base
* Illuminate\Http\Request 직접 주입을 피하고 모듈/플러그인의 동적 규칙 확장 지점을
* 제공하기 위한 전용 서브클래스입니다.
*/
class AdminIdentityPolicyDestroyRequest extends FormRequest
{
/**
* 인증/권한은 route middleware 가 담당 — FormRequest 는 true 고정.
*
* @return bool 항상 true (권한 판정은 미들웨어 책임)
*/
public function authorize(): bool
{
return true;
}
/**
* 검증 규칙 — 삭제는 라우트 {id} 만 사용하므로 본문 규칙은 없으나,
* 확장이 동적 규칙을 주입할 수 있도록 필터 훅을 통과시킵니다.
*
* @return array<string, array<int, mixed>> 검증 규칙
*/
public function rules(): array
{
$rules = [];
return HookManager::applyFilters('core.identity_policy.destroy_validation_rules', $rules, $this);
}
}
@@ -2,6 +2,7 @@
namespace App\Http\Requests\Identity;
use App\Extension\HookManager;
use Illuminate\Foundation\Http\FormRequest;
/**
@@ -15,7 +16,7 @@ class AdminIdentityPolicyResetFieldRequest extends FormRequest
/**
* 인증/권한은 route middleware 가 담당 — FormRequest 는 true 고정.
*
* @return bool
* @return bool 항상 true (권한 판정은 미들웨어 책임)
*/
public function authorize(): bool
{
@@ -29,8 +30,10 @@ class AdminIdentityPolicyResetFieldRequest extends FormRequest
*/
public function rules(): array
{
return [
'field' => ['required', 'string', 'in:enabled,grace_minutes,provider_id,fail_mode,conditions'],
$rules = [
'field' => ['required', 'string', 'in:enabled,grace_minutes,provider_id,fail_mode,conditions,purpose,applies_to,priority'],
];
return HookManager::applyFilters('core.identity_policy.reset_field_validation_rules', $rules, $this);
}
}
@@ -5,7 +5,9 @@ namespace App\Http\Requests\Identity;
use App\Enums\IdentityPolicyAppliesTo;
use App\Enums\IdentityPolicyFailMode;
use App\Enums\IdentityPolicyScope;
use App\Extension\HookManager;
use App\Models\IdentityPolicy;
use App\Rules\UniquePolicyPriorityPerTarget;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
@@ -19,7 +21,7 @@ class AdminIdentityPolicyStoreRequest extends FormRequest
/**
* 요청 권한 — 라우트 permission 미들웨어가 담당하므로 true 고정.
*
* @return bool
* @return bool 항상 true (권한 판정은 미들웨어 책임)
*/
public function authorize(): bool
{
@@ -33,7 +35,7 @@ class AdminIdentityPolicyStoreRequest extends FormRequest
*/
public function rules(): array
{
return [
$rules = [
'key' => ['required', 'string', 'max:120', Rule::unique(IdentityPolicy::class, 'key')],
'scope' => ['required', Rule::enum(IdentityPolicyScope::class)],
'target' => ['required', 'string', 'max:255'],
@@ -41,7 +43,18 @@ class AdminIdentityPolicyStoreRequest extends FormRequest
'provider_id' => ['nullable', 'string', 'max:64'],
'grace_minutes' => ['required', 'integer', 'min:0', 'max:43200'],
'enabled' => ['boolean'],
'priority' => ['integer', 'min:0', 'max:65535'],
// priority 동률 차단 — 같은 scope+target 에 동일 priority 활성 정책이 이미 있으면 거부.
// 동률 시 적용 순서 비결정성 을 저장 시점에 원천 봉쇄.
'priority' => [
'integer',
'min:0',
'max:65535',
new UniquePolicyPriorityPerTarget(
scope: (string) $this->input('scope', ''),
target: (string) $this->input('target', ''),
enabled: $this->boolean('enabled'),
),
],
'conditions' => ['nullable', 'array'],
'applies_to' => ['required', Rule::enum(IdentityPolicyAppliesTo::class)],
'fail_mode' => ['required', Rule::enum(IdentityPolicyFailMode::class)],
@@ -50,6 +63,8 @@ class AdminIdentityPolicyStoreRequest extends FormRequest
// 모듈/플러그인 sync 경로 및 목록 필터가 모두 raw identifier 컨벤션을 사용하므로 동일하게 통일.
'source_identifier' => ['nullable', 'string', 'max:100', 'regex:/^[a-z][a-z0-9_\-]*$/'],
];
return HookManager::applyFilters('core.identity_policy.store_validation_rules', $rules, $this);
}
/**
@@ -2,24 +2,29 @@
namespace App\Http\Requests\Identity;
use App\Contracts\Repositories\IdentityPolicyRepositoryInterface;
use App\Enums\IdentityPolicyAppliesTo;
use App\Enums\IdentityPolicyFailMode;
use App\Enums\IdentityPolicyScope;
use App\Extension\HookManager;
use App\Models\IdentityPolicy;
use App\Rules\UniquePolicyPriorityPerTarget;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
/**
* 운영자가 IDV 정책을 수정할 때의 검증.
*
* source_type != 'admin' 정책은 enabled/grace_minutes/provider_id/fail_mode 4개 필드만 허용됩니다.
* (key/scope/target/conditions 등은 readonly — 선언형 Seeder 의 SSoT 유지를 위해 Controller 에서 필터링)
* source_type != 'admin' 정책은 키(key)/시점(scope)/위치(target) 만 readonly 이며 (확장이 발행하는
* 훅/라우트 지점 식별자라 변경 시 정책이 지점과 어긋남), 그 외 필드는 운영자가 자유로이 편집할 수
* 있습니다 — Controller 의 LIMITED_EDITABLE_FIELDS 화이트리스트가 key/scope/target 만 필터링합니다.
*/
class AdminIdentityPolicyUpdateRequest extends FormRequest
{
/**
* 요청 권한 — 라우트 permission 미들웨어가 담당하므로 true 고정.
*
* @return bool
* @return bool 항상 true (권한 판정은 미들웨어 책임)
*/
public function authorize(): bool
{
@@ -33,7 +38,7 @@ class AdminIdentityPolicyUpdateRequest extends FormRequest
*/
public function rules(): array
{
return [
$rules = [
'enabled' => ['sometimes', 'boolean'],
'grace_minutes' => ['sometimes', 'integer', 'min:0', 'max:43200'],
'provider_id' => ['sometimes', 'nullable', 'string', 'max:64'],
@@ -44,10 +49,87 @@ class AdminIdentityPolicyUpdateRequest extends FormRequest
'scope' => ['sometimes', Rule::enum(IdentityPolicyScope::class)],
'target' => ['sometimes', 'string', 'max:255'],
'purpose' => ['sometimes', 'string', 'max:64'],
'priority' => ['sometimes', 'integer', 'min:0', 'max:65535'],
// priority 동률 차단 — 같은 scope+target 에 동일 priority 활성 정책이 이미 있으면 거부 (자기 자신 제외).
// scope/target/enabled 는 요청에 없으면 기존 정책 값으로 폴백 (선언형 정책은 scope/target 변경 불가).
'priority' => [
'sometimes',
'integer',
'min:0',
'max:65535',
new UniquePolicyPriorityPerTarget(
scope: $this->effectiveScope(),
target: $this->effectiveTarget(),
enabled: $this->effectiveEnabled(),
ignoreId: $this->currentPolicy()?->id,
),
],
'conditions' => ['sometimes', 'nullable', 'array'],
'applies_to' => ['sometimes', Rule::enum(IdentityPolicyAppliesTo::class)],
];
return HookManager::applyFilters('core.identity_policy.update_validation_rules', $rules, $this);
}
/**
* 동일 요청 내 1회 조회 캐시 (false = 미조회). static 금지 — 인스턴스별로 격리해야
* 한 프로세스에서 여러 요청이 처리되는 환경(테스트 러너 등)에서 이전 요청의 정책이
* 재사용되는 오염을 방지한다.
*/
private IdentityPolicy|null|false $cachedPolicy = false;
/**
* 수정 대상 정책을 라우트 {id} 로 1회 조회해 캐싱합니다 (priority 동률 검사용 폴백).
*
* @return IdentityPolicy|null 대상 정책 또는 null
*/
protected function currentPolicy(): ?IdentityPolicy
{
if ($this->cachedPolicy === false) {
$id = $this->route('id');
$this->cachedPolicy = is_numeric($id)
? app(IdentityPolicyRepositoryInterface::class)->findById((int) $id)
: null;
}
return $this->cachedPolicy;
}
/**
* 동률 검사에 사용할 scope — 요청에 있으면 그 값, 없으면 기존 정책 값.
*/
protected function effectiveScope(): string
{
$scope = $this->input('scope');
if (is_string($scope) && $scope !== '') {
return $scope;
}
return (string) ($this->currentPolicy()?->scope?->value ?? '');
}
/**
* 동률 검사에 사용할 target — 요청에 있으면 그 값, 없으면 기존 정책 값.
*/
protected function effectiveTarget(): string
{
$target = $this->input('target');
if (is_string($target) && $target !== '') {
return $target;
}
return (string) ($this->currentPolicy()?->target ?? '');
}
/**
* 동률 검사에 사용할 enabled — 요청에 있으면 그 값, 없으면 기존 정책 값.
*/
protected function effectiveEnabled(): bool
{
if ($this->has('enabled')) {
return $this->boolean('enabled');
}
return (bool) ($this->currentPolicy()?->enabled ?? false);
}
/**
@@ -0,0 +1,80 @@
<?php
namespace App\Http\Requests\Layout;
use App\Extension\HookManager;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
/**
* 레이아웃 확장 미리보기 생성 요청 검증
*
* 편집 중인 확장 content를 임시 저장하여, 대표 레이아웃에 적용한 미리보기를 생성합니다.
*/
class StoreLayoutExtensionPreviewRequest extends FormRequest
{
/**
* 사용자가 이 요청을 수행할 권한이 있는지 확인
*
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
*
* @return bool 항상 true (권한은 미들웨어 체인에서 처리)
*/
public function authorize(): bool
{
return true;
}
/**
* 검증 전 데이터 전처리
*
* content가 JSON 문자열로 전송된 경우 배열로 변환합니다.
*/
protected function prepareForValidation(): void
{
$content = $this->input('content');
if (is_string($content)) {
$decoded = json_decode($content, true);
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
$this->merge(['content' => $decoded]);
}
}
}
/**
* 요청에 적용할 검증 규칙
*
* preview_layout: 미리보기에 사용할 대표 레이아웃명.
* - overlay 타입은 target_layout 자체가 대표 레이아웃이므로 생략 가능.
* - extension_point 타입은 프론트가 선택한 레이아웃명을 전달.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$rules = [
'content' => ['required', 'array'],
'preview_layout' => ['nullable', 'string', 'max:255'],
];
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
return HookManager::applyFilters('core.layout_extension.store_preview_validation_rules', $rules, $this);
}
/**
* 검증 오류 메시지 커스터마이징
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'content.required' => __('validation.layout_extension.content.required'),
'content.array' => __('validation.layout_extension.content.array'),
'preview_layout.string' => __('validation.layout_extension.preview_layout.string'),
'preview_layout.max' => __('validation.layout_extension.preview_layout.max'),
];
}
}
@@ -2,6 +2,7 @@
namespace App\Http\Requests\Layout;
use App\Contracts\Repositories\TemplateRepositoryInterface;
use App\Extension\HookManager;
use App\Rules\NoExternalUrls;
use App\Rules\ValidDataSourceMerge;
@@ -11,6 +12,8 @@ use App\Rules\ValidPermissionStructure;
use App\Rules\ValidSlotStructure;
use App\Rules\WhitelistedEndpoint;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
@@ -26,6 +29,8 @@ class UpdateLayoutContentRequest extends FormRequest
* 사용자가 이 요청을 수행할 권한이 있는지 확인
*
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
*
* @return bool 항상 true (권한은 미들웨어 체인에서 처리)
*/
public function authorize(): bool
{
@@ -52,21 +57,184 @@ class UpdateLayoutContentRequest extends FormRequest
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
$this->merge(['content' => $decoded]);
$content = $decoded;
}
// JSON 파싱 실패 시 원본 유지 (검증에서 'array' 규칙으로 실패 처리)
}
// 편집기 응답의 상속/주입/partial 노드 + 편집기 전용 메타 제거.
// 클라이언트 1차 마스킹(`stripInheritedFromLayoutContent`)이 누락/우회되어도 백엔드가
// 최종 방어선으로 같은 정책을 적용한다. 정책 상세는 클라이언트 동명 함수 주석 참조.
if (is_array($content)) {
$this->merge(['content' => $this->stripInheritedFromLayoutContent($content)]);
}
// 라우트 파라미터에서 templateName을 가져와 template_id로 변환
// ValidParentLayout 규칙에서 template_id를 사용하기 때문에 필요
// Service-Repository 패턴: Model facade 직접 호출 금지 → Repository Interface 경유.
$templateName = $this->route('templateName');
if ($templateName && ! $this->has('template_id')) {
$template = \App\Models\Template::where('identifier', $templateName)->first();
$template = app(TemplateRepositoryInterface::class)->findByIdentifier($templateName);
if ($template) {
$this->merge(['template_id' => $template->id]);
}
}
}
/**
* 레이아웃 content 페이로드에서 상속/주입/partial 노드와 편집기 전용 메타를 제거.
*
* 편집 모드 응답(`with_source_meta=1`)은 자식 레이아웃의 슬롯에 base 레이아웃 노드를
* 머지해 노출한다. 이 메타 노드들이 그대로 자식 레이아웃 content 로 저장되면 다음
* 로드 시 머지가 중복되거나 base/확장/partial 의 변경이 자식에 박힌 사본에 가려진다.
*
* 정책 (클라이언트 `stripInheritedFromLayoutContent` 와 동일):
* - `__editor.original` 은 자식 레이아웃의 **구조 메타** (extends, slots 이름, meta,
* data_sources 등) 의 SSoT 일 뿐, **콘텐츠의 SSoT 가 아니다**. 콘텐츠는 사용자가
* 캔버스에서 누적 편집한 머지된 components 트리에서 마스킹으로 추출한다.
* - 1) 머지된 components 트리를 마스킹 → 본 자식 레이아웃의 route 콘텐츠만 남김
* - 2) `__editor.original` 의 구조 메타를 골격으로 차용, 콘텐츠 자리는 1) 결과로 채움
* - 3) extends 가 있으면 components 키 제거 + slots 로 재구성, 없으면 components 사용
* - 4) 응답 전용 메타 키(`lock_version`, `__editor`) 제거
*
* @param array<string, mixed> $content
* @return array<string, mixed>
*/
private function stripInheritedFromLayoutContent(array $content): array
{
// 응답 전용 메타 키 제거 (어느 경로든 페이로드에 박히면 안 됨)
$content_clean = $content;
unset($content_clean['lock_version'], $content_clean['__editor']);
$hasMergedComponents = is_array($content['components'] ?? null) && ! empty($content['components']);
$hasSlots = is_array($content['slots'] ?? null);
$hasExtends = isset($content_clean['extends']) && is_string($content_clean['extends']) && $content_clean['extends'] !== '';
// 경로 A — 클라이언트가 이미 마스킹한 결과 (extends + slots, components 없음 또는 빈 배열).
// 클라이언트 1차 마스킹의 정상 페이로드. components 트리에서 다시 추출하지 않고
// slots 안의 각 콘텐츠만 안전망 마스킹 (재마스킹은 메타가 없으므로 no-op 에 가까움).
if ($hasExtends && $hasSlots && ! $hasMergedComponents) {
$nextSlots = [];
foreach ($content_clean['slots'] as $slotName => $slotValue) {
$nextSlots[$slotName] = is_array($slotValue)
? $this->stripInheritedNodes($slotValue)
: $slotValue;
}
$content_clean['slots'] = $nextSlots;
unset($content_clean['components']);
return $content_clean;
}
// 경로 B — 머지된 components 트리가 포함된 페이로드 (편집기 응답 그대로 우회 전송).
// route 콘텐츠 추출 후 골격에 매핑.
$original = is_array($content['__editor']['original'] ?? null)
? $content['__editor']['original']
: null;
$maskedComponents = $hasMergedComponents
? $this->stripInheritedNodes($content['components'])
: [];
$skeleton = $original !== null ? $original : $content_clean;
unset($skeleton['lock_version'], $skeleton['__editor']);
$skeletonHasExtends = isset($skeleton['extends']) && is_string($skeleton['extends']) && $skeleton['extends'] !== '';
if ($skeletonHasExtends) {
unset($skeleton['components']);
$skeletonSlots = is_array($skeleton['slots'] ?? null) ? $skeleton['slots'] : [];
$slotNames = array_keys($skeletonSlots);
if (count($slotNames) === 1) {
$skeleton['slots'] = [$slotNames[0] => $maskedComponents];
} elseif (count($slotNames) === 0) {
$skeleton['slots'] = ['content' => $maskedComponents];
} else {
$nextSlots = [];
foreach ($skeletonSlots as $slotName => $slotValue) {
$nextSlots[$slotName] = is_array($slotValue)
? $this->stripInheritedNodes($slotValue)
: $slotValue;
}
$skeleton['slots'] = $nextSlots;
}
} else {
$skeleton['components'] = $maskedComponents;
unset($skeleton['slots']);
}
return $skeleton;
}
/**
* components 배열 마스킹 — 노드 종류에 따라 0개·1개·N개를 펼쳐 누적.
*
* @param array<int, mixed> $components
* @return array<int, array<string, mixed>>
*/
private function stripInheritedNodes(array $components): array
{
$result = [];
foreach ($components as $node) {
if (! is_array($node)) {
continue;
}
$cleanedList = $this->stripInheritedNode($node);
foreach ($cleanedList as $cleaned) {
$result[] = $cleaned;
}
}
return $result;
}
/**
* 단일 노드 마스킹 — 노드 종류에 따라 0개·1개·N개를 반환.
*
* `LayoutService::replaceSlots` 가 머지할 때:
* - **slot 래퍼**: `__source.kind === 'base'` + `_fromBase` 부재. base 가 정의한
* 슬롯 위치 컨테이너로, 그 안에 자식 레이아웃의 route 콘텐츠가 끼워진다.
* 슬롯 자체는 base 소유지만 안의 콘텐츠는 자식 레이아웃 소속이므로,
* **자체는 버리되 children 을 부모 배열로 끌어올린다** (재귀 마스킹).
* - **일반 base 노드**: `__source.kind === 'base'` + `_fromBase: true`. 헤더/사이드바
* /푸터 등 자식 레이아웃에 속하지 않는 base 콘텐츠 → 통째 제거.
* - extension/partial 노드: 통째 제거 (별도 SSoT 가 책임).
* - route 또는 메타 미부여 노드: 보존 + 메타 제거 + children 재귀 마스킹.
*
* @param array<string, mixed> $node
* @return array<int, array<string, mixed>>
*/
private function stripInheritedNode(array $node): array
{
$fromBase = ($node['_fromBase'] ?? false) === true;
$kind = is_array($node['__source'] ?? null) ? ($node['__source']['kind'] ?? null) : null;
// extension/partial 노드 — 통째 제거
if ($kind === 'extension' || $kind === 'partial') {
return [];
}
// base 출처 노드 (slot 래퍼 또는 일반 base 노드) — 자체는 버리되 children 의 route
// 콘텐츠는 끌어올린다. `LayoutService::replaceSlots` 가 base 의 깊은 자손에 slot
// 래퍼를 두고 그 안에 route 콘텐츠를 끼우므로, base 노드를 무조건 제거하면 그
// 자손의 route 콘텐츠까지 사라진다.
if ($kind === 'base' || $fromBase) {
$children = is_array($node['children'] ?? null) ? $node['children'] : [];
return $this->stripInheritedNodes($children);
}
unset($node['__source'], $node['_fromBase']);
if (isset($node['children']) && is_array($node['children'])) {
$node['children'] = $this->stripInheritedNodes($node['children']);
}
return [$node];
}
/**
* 요청에 적용할 검증 규칙
*
@@ -74,7 +242,7 @@ class UpdateLayoutContentRequest extends FormRequest
* - standalone: endpoint, components 필수
* - extends: extends, slots 사용 (endpoint, components는 부모에서 상속)
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@@ -87,6 +255,11 @@ class UpdateLayoutContentRequest extends FormRequest
$isBaseLayout = is_array($content) && isset($content['slots']) && is_array($content['slots']);
$rules = [
// 낙관적 잠금 — 클라이언트가 로드한 시점의 lock_version 필수 전달
// Service::updateLayout 가 현재 DB lock_version 과 비교해 불일치 시
// ConcurrentModificationException 으로 409 반환
'expected_lock_version' => ['required', 'integer', 'min:0'],
// content 전체 검증 (ValidLayoutStructure에서 extends/standalone 분기 처리)
'content' => [
'required',
@@ -132,13 +305,24 @@ class UpdateLayoutContentRequest extends FormRequest
'content.metadata' => ['nullable', 'array'],
// 메타 정보 (title, description, auth_required 등)
// 주의: content.meta 는 'array' 규칙 + 하위 키 일부 명시 조합이므로 Laravel validated()
// 는 명시된 하위 키만 추출한다(미명시 키는 저장 시 누락). 엔진이 소비하는 meta 하위 키는
// 빠짐없이 명시해야 한다.
'content.meta' => ['nullable', 'array'],
'content.meta.title' => ['nullable', 'string'],
'content.meta.description' => ['nullable', 'string'],
'content.meta.keywords' => ['nullable', 'string'],
'content.meta.auth_required' => ['nullable', 'boolean'],
'content.meta.is_base' => ['nullable', 'boolean'],
// 비로그인 전용 라우트 표식 — _redirect_if_logged_in 가드 + SEO/sitemap 제외 판정에 소비
'content.meta.guest_only' => ['nullable', 'boolean'],
// 에러 레이아웃 표식 — ErrorPageHandler 가 소비
'content.meta.is_error_layout' => ['nullable', 'boolean'],
'content.meta.error_code' => ['nullable', 'integer'],
// SEO 메타데이터
// 주의: content.meta.seo 도 'array' 규칙 + 하위 키 일부 명시이므로 SEO 페이지 생성기가
// 소비하는 모든 하위 키를 명시해야 validated 에서 보존된다.
'content.meta.seo' => ['nullable', 'array'],
'content.meta.seo.enabled' => ['nullable', 'boolean'],
'content.meta.seo.data_sources' => ['nullable', 'array'],
@@ -147,6 +331,11 @@ class UpdateLayoutContentRequest extends FormRequest
'content.meta.seo.changefreq' => ['nullable', 'string', 'in:always,hourly,daily,weekly,monthly,yearly,never'],
'content.meta.seo.og' => ['nullable', 'array'],
'content.meta.seo.structured_data' => ['nullable', 'array'],
// SEO 페이지 생성기 소비 키 (SeoRenderer/TemplateRouteResolver)
'content.meta.seo.page_type' => ['nullable', 'string'],
'content.meta.seo.toggle_setting' => ['nullable', 'string'],
'content.meta.seo.vars' => ['nullable', 'array'],
'content.meta.seo.extensions' => ['nullable', 'array'],
// 모달 컴포넌트 정의
'content.modals' => ['nullable', 'array'],
@@ -163,6 +352,26 @@ class UpdateLayoutContentRequest extends FormRequest
// 초기 상태 (init_state - state의 대체 키)
'content.init_state' => ['nullable', 'array'],
// 데이터소스 병합 전 정적 로컬/전역/격리 상태 초기값 (TemplateApp 가 소비)
// [초기 상태] 탭의 컴포넌트 격리 상태 초기값(initIsolated)
// 추가. 미명시 시 validated() 가 떨궈 격리 초기값이 저장되지 않음(R9 누락 가드).
'content.initLocal' => ['nullable', 'array'],
'content.initGlobal' => ['nullable', 'array'],
'content.initIsolated' => ['nullable', 'array'],
// 전역 상태 초기값 (레이아웃 레벨 _global 초기화)
'content.global_state' => ['nullable', 'array'],
// 에러 핸들링 정책 (상태 코드별 handler — ErrorHandlingResolver 가 소비)
'content.errorHandling' => ['nullable', 'array'],
// 레이아웃 레벨 재사용 액션 정의 (ActionDispatcher 가 id 로 참조)
'content.actions' => ['nullable', 'array'],
// 플러그인 설정 레이아웃 전용 — 안내/스키마 (settings UI 렌더가 소비)
'content.pageConfig' => ['nullable', 'array'],
'content.schema' => ['nullable', 'array'],
// 라우트 정의
'content.routes' => ['nullable', 'array'],
@@ -201,27 +410,29 @@ class UpdateLayoutContentRequest extends FormRequest
'content.transition_overlay.wait_for.*' => ['string', 'max:100'],
];
// extends 레이아웃 또는 Base 레이아웃이 아닌 경우에만 endpoint, components 필수
// - extends 레이아웃: 부모로부터 endpoint 상속
// - Base 레이아웃 (slots 정의): 자식 레이아웃이 endpoint 정의
// content.endpoint 는 항상 선택적(nullable)이다.
//
// 최상위 endpoint 는 화면이 주로 fetch 하는 데이터 API 경로를 가리키는 레거시 필드로,
// 로그인/대시보드/정적 페이지처럼 주 데이터 fetch 가 없는 standalone 레이아웃은 정당하게
// endpoint 가 없다(번들 admin 103 + basic 39 = 전 142 레이아웃이 endpoint 부재 상태로
// 정상 렌더·동작). 구조 SSoT(ValidLayoutStructure) 도 endpoint 를 필수로 요구하지 않으며,
// 런타임 어디에서도 최상위 endpoint 를 소비하지 않는다(데이터소스의 endpoint 만 사용).
//
// 과거 standalone 분기에서 endpoint 를 required 로 강제하던 규칙은, endpoint 없이 잘
// 동작하던 전 레이아웃을 편집기로 컴포넌트만 추가해 저장하려 해도 422 로 막는 회귀를
// 일으켰다. endpoint 가 명시되면 whitelist/외부URL 차단 검증은 그대로 적용한다.
$rules['content.endpoint'] = [
'nullable',
'string',
new WhitelistedEndpoint,
new NoExternalUrls,
];
if (! $isExtending && ! $isBaseLayout) {
$rules['content.endpoint'] = [
'required',
'string',
new WhitelistedEndpoint,
new NoExternalUrls,
];
// standalone 레이아웃은 components 필수 (ValidLayoutStructure 와 동일 계약)
$rules['content.components'] = ['required', 'array'];
} else {
// extends 또는 Base 레이아웃은 endpoint가 선택적
$rules['content.endpoint'] = [
'nullable',
'string',
new WhitelistedEndpoint,
new NoExternalUrls,
];
// extends 레이아웃은 components 또는 slots 중 하나 사용
// ValidLayoutStructure에서 상세 검증
// extends 레이아웃은 components 또는 slots 중 하나 사용 — ValidLayoutStructure 에서 상세 검증
$rules['content.components'] = ['nullable', 'array'];
}
@@ -234,10 +445,12 @@ class UpdateLayoutContentRequest extends FormRequest
*
* wait_for 는 spinner 가 fetch 완료까지 표시되어야 할 데이터소스 ID 목록이지만,
* 의미상 사용자를 차단할 수 없는 background/websocket 데이터소스는 사전에 차단한다.
*
* @param Validator $validator Laravel 검증기 인스턴스
*/
public function withValidator(\Illuminate\Contracts\Validation\Validator $validator): void
public function withValidator(Validator $validator): void
{
$validator->after(function (\Illuminate\Contracts\Validation\Validator $v): void {
$validator->after(function (Validator $v): void {
$waitFor = $this->input('content.transition_overlay.wait_for');
if (! is_array($waitFor) || empty($waitFor)) {
return;
@@ -285,6 +498,9 @@ class UpdateLayoutContentRequest extends FormRequest
public function messages(): array
{
return [
'expected_lock_version.required' => __('validation.layout.expected_lock_version.required'),
'expected_lock_version.integer' => __('validation.layout.expected_lock_version.integer'),
'expected_lock_version.min' => __('validation.layout.expected_lock_version.min'),
'content.required' => __('validation.layout.content.required'),
'content.array' => __('validation.layout.content.array'),
'content.version.required' => __('validation.layout.version.required'),
@@ -292,7 +508,7 @@ class UpdateLayoutContentRequest extends FormRequest
'content.layout_name.required' => __('validation.layout.layout_name.required'),
'content.layout_name.string' => __('validation.layout.layout_name.string'),
'content.layout_name.max' => __('validation.layout.layout_name.max'),
'content.endpoint.required' => __('validation.layout.endpoint.required'),
// content.endpoint 는 nullable 이므로 required 메시지 키는 더 이상 발화되지 않는다.
'content.endpoint.string' => __('validation.layout.endpoint.string'),
'content.extends.string' => __('validation.layout.extends.string'),
'content.slots.array' => __('validation.layout.slots.array'),
@@ -303,8 +519,12 @@ class UpdateLayoutContentRequest extends FormRequest
'content.meta.array' => __('validation.layout.meta.array'),
'content.meta.title.string' => __('validation.layout.meta.title.string'),
'content.meta.description.string' => __('validation.layout.meta.description.string'),
'content.meta.keywords.string' => __('validation.layout.meta.keywords.string'),
'content.meta.auth_required.boolean' => __('validation.layout.meta.auth_required.boolean'),
'content.meta.is_base.boolean' => __('validation.layout.meta.is_base.boolean'),
'content.meta.guest_only.boolean' => __('validation.layout.meta.guest_only.boolean'),
'content.meta.is_error_layout.boolean' => __('validation.layout.meta.is_error_layout.boolean'),
'content.meta.error_code.integer' => __('validation.layout.meta.error_code.integer'),
'content.meta.seo.array' => __('validation.layout.meta.seo.array'),
'content.meta.seo.enabled.boolean' => __('validation.layout.meta.seo.enabled.boolean'),
'content.meta.seo.data_sources.array' => __('validation.layout.meta.seo.data_sources.array'),
@@ -316,11 +536,22 @@ class UpdateLayoutContentRequest extends FormRequest
'content.meta.seo.changefreq.in' => __('validation.layout.meta.seo.changefreq.in'),
'content.meta.seo.og.array' => __('validation.layout.meta.seo.og.array'),
'content.meta.seo.structured_data.array' => __('validation.layout.meta.seo.structured_data.array'),
'content.meta.seo.page_type.string' => __('validation.layout.meta.seo.page_type.string'),
'content.meta.seo.toggle_setting.string' => __('validation.layout.meta.seo.toggle_setting.string'),
'content.meta.seo.vars.array' => __('validation.layout.meta.seo.vars.array'),
'content.meta.seo.extensions.array' => __('validation.layout.meta.seo.extensions.array'),
'content.modals.array' => __('validation.layout.modals.array'),
'content.state.array' => __('validation.layout.state.array'),
'content.init_actions.array' => __('validation.layout.init_actions.array'),
'content.defines.array' => __('validation.layout.defines.array'),
'content.init_state.array' => __('validation.layout.init_state.array'),
'content.initLocal.array' => __('validation.layout.initLocal.array'),
'content.initGlobal.array' => __('validation.layout.initGlobal.array'),
'content.global_state.array' => __('validation.layout.global_state.array'),
'content.errorHandling.array' => __('validation.layout.errorHandling.array'),
'content.actions.array' => __('validation.layout.actions.array'),
'content.pageConfig.array' => __('validation.layout.pageConfig.array'),
'content.schema.array' => __('validation.layout.schema.array'),
'content.routes.array' => __('validation.layout.routes.array'),
'content.computed.array' => __('validation.layout.computed.array'),
'content.permissions' => __('validation.layout.permissions.array'),
@@ -0,0 +1,111 @@
<?php
namespace App\Http\Requests\Layout;
use App\Extension\HookManager;
use App\Rules\NoExternalUrls;
use App\Rules\ValidDataSourceMerge;
use App\Rules\ValidLayoutExtensionStructure;
use App\Rules\WhitelistedEndpoint;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
/**
* 레이아웃 확장 Content 업데이트 요청 검증
*
* 레이아웃 확장(extension_point / overlay)의 content JSON 구조를 검증합니다.
*/
class UpdateLayoutExtensionContentRequest extends FormRequest
{
/**
* 사용자가 이 요청을 수행할 권한이 있는지 확인
*
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
*
* @return bool 항상 true (권한은 미들웨어 체인에서 처리)
*/
public function authorize(): bool
{
return true;
}
/**
* 검증 전 데이터 전처리
*
* content가 JSON 문자열로 전송된 경우 배열로 변환합니다.
*/
protected function prepareForValidation(): void
{
$content = $this->input('content');
if (is_string($content)) {
$decoded = json_decode($content, true);
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
$this->merge(['content' => $decoded]);
}
}
}
/**
* 요청에 적용할 검증 규칙
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$rules = [
// 낙관적 잠금 — 클라이언트가 로드한 시점의 lock_version 필수 전달
'expected_lock_version' => ['required', 'integer', 'min:0'],
'content' => [
'required',
'array',
new ValidLayoutExtensionStructure,
],
// 우선순위 (선택 — content.priority 와 별개로 직접 지정 가능)
'priority' => ['nullable', 'integer', 'min:0', 'max:9999'],
// content 내부 priority
'content.priority' => ['nullable', 'integer', 'min:0', 'max:9999'],
// 데이터소스 검증
'content.data_sources' => ['nullable', 'array', new ValidDataSourceMerge],
// 데이터소스 endpoint 검증
'content.data_sources.*.endpoint' => [
'nullable',
'string',
new WhitelistedEndpoint,
new NoExternalUrls,
],
];
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
return HookManager::applyFilters('core.layout_extension.update_content_validation_rules', $rules, $this);
}
/**
* 검증 오류 메시지 커스터마이징
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'expected_lock_version.required' => __('validation.layout_extension.expected_lock_version.required'),
'expected_lock_version.integer' => __('validation.layout_extension.expected_lock_version.integer'),
'expected_lock_version.min' => __('validation.layout_extension.expected_lock_version.min'),
'content.required' => __('validation.layout_extension.content.required'),
'content.array' => __('validation.layout_extension.content.array'),
'priority.integer' => __('validation.layout_extension.priority.integer'),
'priority.min' => __('validation.layout_extension.priority.min'),
'priority.max' => __('validation.layout_extension.priority.max'),
'content.priority.integer' => __('validation.layout_extension.priority.integer'),
'content.priority.min' => __('validation.layout_extension.priority.min'),
'content.priority.max' => __('validation.layout_extension.priority.max'),
'content.data_sources.array' => __('validation.layout_extension.data_sources.array'),
];
}
}
@@ -6,6 +6,7 @@ use App\Extension\HookManager;
use App\Models\Attachment;
use App\Search\Engines\DatabaseFulltextEngine;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
@@ -69,7 +70,7 @@ class SaveSettingsRequest extends FormRequest
/**
* Determine if the user is authorized to make this request.
*
* @return bool
* @return bool 권한 체크는 permission 미들웨어 체인이 담당하므로 항상 true 반환
*/
public function authorize(): bool
{
@@ -291,7 +292,6 @@ class SaveSettingsRequest extends FormRequest
// 본인인증(IDV) provider 기술 파라미터 — 정책 분기는 IdentityPolicy 로 흡수됨
'identity.default_provider' => ['nullable', 'string', 'max:100'],
'identity.purpose_providers' => ['sometimes', 'array'],
'identity.purpose_providers.*' => ['nullable', 'string', 'max:100'],
'identity.challenge_ttl_minutes' => $this->getTabRules($tab, 'identity', 'integer|min:1|max:1440'),
'identity.max_attempts' => $this->getTabRules($tab, 'identity', 'integer|min:1|max:20'),
];
@@ -422,6 +422,73 @@ class SaveSettingsRequest extends FormRequest
]);
}
/**
* 추가 검증을 위해 validator after 콜백을 등록합니다.
*
* 목적별 프로바이더(purpose_providers) 매핑은 purpose id 에 점(.)이 포함될 수
* 있어 단일 깊이 와일드카드 룰로는 leaf 값을 검증할 수 없습니다.
* 임의 깊이의 leaf 값을 재귀 순회하며 string|max:100 으로 검증합니다.
*
* @param Validator $validator 검증기 인스턴스
*/
public function withValidator($validator): void
{
$validator->after(function ($validator) {
$purposeProviders = $this->input('identity.purpose_providers');
if (is_array($purposeProviders)) {
$this->validatePurposeProviderLeaves(
$purposeProviders,
'identity.purpose_providers',
$validator
);
}
});
}
/**
* 목적별 프로바이더 매핑을 재귀 순회하며 leaf 값을 검증합니다.
*
* purpose id 에 점(.)이 포함될 수 있습니다 (예: KG이니시스 플러그인의
* `inicis.adult_verification`). 프론트엔드 폼 자동 바인딩이 dot-notation name
* (`identity.purpose_providers.inicis.adult_verification`) 을 중첩 객체로 풀어
* `purpose_providers.inicis = { adult_verification: '...' }` 형태로 전송하므로,
* 깊이에 무관하게 각 leaf 값을 검증하고 위반 시 전체 dot-path 키로 에러를 부착합니다.
* 백엔드 조회(IdentityVerificationManager::resolveForPurpose) 가 config dot-path
* 라 이 중첩 구조 자체는 정상입니다.
*
* @param array<string, mixed> $node 검증할 노드 (purpose_providers 또는 중첩 하위)
* @param string $path 현재 노드의 dot-path (에러 키 prefix)
* @param Validator $validator 검증기 인스턴스
*/
private function validatePurposeProviderLeaves(array $node, string $path, $validator): void
{
foreach ($node as $key => $value) {
$childPath = $path.'.'.$key;
if (is_array($value)) {
$this->validatePurposeProviderLeaves($value, $childPath, $validator);
continue;
}
// null / '' (기본 프로바이더 사용) 은 허용
if ($value === null || $value === '') {
continue;
}
if (! is_string($value)) {
$validator->errors()->add($childPath, __('validation.settings.identity_purpose_provider_string'));
continue;
}
if (mb_strlen($value) > 100) {
$validator->errors()->add($childPath, __('validation.settings.identity_purpose_provider_max'));
}
}
}
/**
* 지원되는 검색엔진 드라이버 목록을 반환합니다.
*
@@ -648,8 +715,8 @@ class SaveSettingsRequest extends FormRequest
'identity.default_provider.string' => __('validation.settings.identity_default_provider_string'),
'identity.default_provider.max' => __('validation.settings.identity_default_provider_max'),
'identity.purpose_providers.array' => __('validation.settings.identity_purpose_providers_array'),
'identity.purpose_providers.*.string' => __('validation.settings.identity_purpose_provider_string'),
'identity.purpose_providers.*.max' => __('validation.settings.identity_purpose_provider_max'),
// 목적별 프로바이더 leaf 값(점 포함 purpose id 대응)은 withValidator() 에서
// validation.settings.identity_purpose_provider_string / _max 를 직접 부착합니다.
'identity.challenge_ttl_minutes.required' => __('validation.settings.identity_challenge_ttl_required'),
'identity.challenge_ttl_minutes.integer' => __('validation.settings.identity_challenge_ttl_integer'),
'identity.challenge_ttl_minutes.min' => __('validation.settings.identity_challenge_ttl_min'),
@@ -0,0 +1,59 @@
<?php
namespace App\Http\Requests\TemplateCustomTranslation;
use App\Extension\HookManager;
use App\Models\TemplateCustomTranslation;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
/**
* 커스텀 다국어 키 일괄 삭제 요청 검증.
*
* 레이아웃 편집기 다국어 관리 모달의 "선택 삭제"/"미사용 전체 삭제" 에서
* 호출됩니다. 권한은 라우트 permission 미들웨어(core.templates.layouts.edit)
* 에서 처리합니다.
*/
class BulkDestroyCustomTranslationRequest extends FormRequest
{
/**
* 권한은 미들웨어 체인에서 처리합니다.
*
* @return bool 항상 true
*/
public function authorize(): bool
{
return true;
}
/**
* 검증 규칙
*
* @return array<string, mixed> 검증 규칙
*/
public function rules(): array
{
$rules = [
'ids' => ['required', 'array', 'min:1'],
'ids.*' => ['integer', Rule::exists(TemplateCustomTranslation::class, 'id')],
];
return HookManager::applyFilters('core.custom_translation.bulk_destroy_validation_rules', $rules, $this);
}
/**
* 검증 실패 메시지
*
* @return array<string, string> 메시지 맵
*/
public function messages(): array
{
return [
'ids.required' => __('validation.custom_translation.ids.required'),
'ids.array' => __('validation.custom_translation.ids.array'),
'ids.min' => __('validation.custom_translation.ids.min'),
'ids.*.integer' => __('validation.custom_translation.ids.integer'),
'ids.*.exists' => __('validation.custom_translation.ids.exists'),
];
}
}
@@ -0,0 +1,53 @@
<?php
namespace App\Http\Requests\TemplateCustomTranslation;
use App\Extension\HookManager;
use Illuminate\Foundation\Http\FormRequest;
/**
* 커스텀 다국어 키 목록 조회 요청 검증.
*
* 권한은 라우트 permission 미들웨어(core.templates.layouts.edit)에서 처리합니다.
*/
class IndexCustomTranslationRequest extends FormRequest
{
/**
* 권한은 미들웨어 체인에서 처리합니다.
*
* @return bool 항상 true
*/
public function authorize(): bool
{
return true;
}
/**
* 검증 규칙
*
* @return array<string, mixed> 검증 규칙
*/
public function rules(): array
{
$rules = [
'layout_name' => ['sometimes', 'nullable', 'string', 'max:150'],
'status' => ['sometimes', 'nullable', 'in:active,orphaned'],
];
return HookManager::applyFilters('core.custom_translation.index_validation_rules', $rules, $this);
}
/**
* 검증 실패 메시지
*
* @return array<string, string> 메시지 맵
*/
public function messages(): array
{
return [
'layout_name.string' => __('validation.custom_translation.layout_name.string'),
'layout_name.max' => __('validation.custom_translation.layout_name.max', ['max' => 150]),
'status.in' => __('validation.custom_translation.status.in'),
];
}
}
@@ -0,0 +1,62 @@
<?php
namespace App\Http\Requests\TemplateCustomTranslation;
use App\Extension\HookManager;
use Illuminate\Foundation\Http\FormRequest;
/**
* 커스텀 다국어 키 생성 요청 검증.
*
* 인라인 편집 확정 시 평문을 동적 다국어 키로 전환할 때 호출됩니다.
* 키(`custom.{layout}.{seq}`)는 Service 가 자동 생성하므로 클라이언트는
* 출처 레이아웃·편집 로케일·입력값만 전달합니다.
*
* 권한은 라우트 permission 미들웨어(core.templates.layouts.edit)에서 처리합니다.
*/
class StoreCustomTranslationRequest extends FormRequest
{
/**
* 권한은 미들웨어 체인에서 처리합니다.
*
* @return bool 항상 true
*/
public function authorize(): bool
{
return true;
}
/**
* 검증 규칙
*
* @return array<string, mixed> 검증 규칙
*/
public function rules(): array
{
$rules = [
'layout_name' => ['required', 'string', 'max:150'],
'locale' => ['required', 'string', 'max:35'],
'value' => ['required', 'string'],
];
return HookManager::applyFilters('core.custom_translation.store_validation_rules', $rules, $this);
}
/**
* 검증 실패 메시지
*
* @return array<string, string> 메시지 맵
*/
public function messages(): array
{
return [
'layout_name.required' => __('validation.custom_translation.layout_name.required'),
'layout_name.string' => __('validation.custom_translation.layout_name.string'),
'layout_name.max' => __('validation.custom_translation.layout_name.max', ['max' => 150]),
'locale.required' => __('validation.custom_translation.locale.required'),
'locale.string' => __('validation.custom_translation.locale.string'),
'value.required' => __('validation.custom_translation.value.required'),
'value.string' => __('validation.custom_translation.value.string'),
];
}
}
@@ -0,0 +1,60 @@
<?php
namespace App\Http\Requests\TemplateCustomTranslation;
use App\Extension\HookManager;
use Illuminate\Foundation\Http\FormRequest;
/**
* 커스텀 다국어 키 수정 요청 검증.
*
* 속성 편집 모달 번역 탭에서 로케일별 값을 일괄 편집할 때 호출됩니다.
* 낙관적 잠금을 위해 `expected_lock_version` 이 필수이며,
* 현재 DB 버전과 불일치 시 Service 가 409 Conflict 를 던집니다.
*
* 권한은 라우트 permission 미들웨어(core.templates.layouts.edit)에서 처리합니다.
*/
class UpdateCustomTranslationRequest extends FormRequest
{
/**
* 권한은 미들웨어 체인에서 처리합니다.
*
* @return bool 항상 true
*/
public function authorize(): bool
{
return true;
}
/**
* 검증 규칙
*
* @return array<string, mixed> 검증 규칙
*/
public function rules(): array
{
$rules = [
'values' => ['required', 'array'],
'values.*' => ['nullable', 'string'],
'expected_lock_version' => ['required', 'integer', 'min:0'],
];
return HookManager::applyFilters('core.custom_translation.update_validation_rules', $rules, $this);
}
/**
* 검증 실패 메시지
*
* @return array<string, string> 메시지 맵
*/
public function messages(): array
{
return [
'values.required' => __('validation.custom_translation.values.required'),
'values.array' => __('validation.custom_translation.values.array'),
'expected_lock_version.required' => __('validation.custom_translation.expected_lock_version.required'),
'expected_lock_version.integer' => __('validation.custom_translation.expected_lock_version.integer'),
'expected_lock_version.min' => __('validation.custom_translation.expected_lock_version.min'),
];
}
}