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,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);
}
/**