## Summary - move the Laravel application into `apps/platform` and keep the repository root for orchestration, docs, and tooling - update the local command model, Sail/Docker wiring, runtime paths, and ignore rules around the new platform location - add relocation quickstart/contracts plus focused smoke coverage for bootstrap, command model, routes, and runtime behavior ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/PlatformRelocation` - integrated browser smoke validated `/up`, `/`, `/admin`, `/admin/choose-workspace`, and tenant route semantics for `200`, `403`, and `404` ## Remaining Rollout Checks - validate Dokploy build context and working-directory assumptions against the new `apps/platform` layout - confirm web, queue, and scheduler processes all start from the expected working directory in staging/production - verify no legacy volume mounts or asset-publish paths still point at the old root-level `public/` or `storage/` locations Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #213
74 lines
2.3 KiB
PHP
74 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\Baselines;
|
|
|
|
use App\Support\Inventory\InventoryPolicyTypeMeta;
|
|
|
|
final class BaselineSubjectKey
|
|
{
|
|
public static function forPolicy(string $policyType, ?string $displayName = null, ?string $subjectExternalId = null): ?string
|
|
{
|
|
return match (InventoryPolicyTypeMeta::baselineCompareIdentityStrategy($policyType)) {
|
|
'external_id' => self::fromExternalId($policyType, $subjectExternalId),
|
|
default => self::fromDisplayName($displayName),
|
|
};
|
|
}
|
|
|
|
public static function fromDisplayName(?string $displayName): ?string
|
|
{
|
|
if (! is_string($displayName)) {
|
|
return null;
|
|
}
|
|
|
|
$trimmed = trim($displayName);
|
|
|
|
if ($trimmed === '') {
|
|
return null;
|
|
}
|
|
|
|
$collapsed = preg_replace('/\\s+/u', ' ', $trimmed);
|
|
$collapsed = is_string($collapsed) ? $collapsed : $trimmed;
|
|
|
|
$normalized = mb_strtolower($collapsed);
|
|
$normalized = trim($normalized);
|
|
|
|
return $normalized !== '' ? $normalized : null;
|
|
}
|
|
|
|
public static function fromExternalId(string $policyType, ?string $subjectExternalId): ?string
|
|
{
|
|
if (! is_string($subjectExternalId)) {
|
|
return null;
|
|
}
|
|
|
|
$normalizedId = trim(mb_strtolower($subjectExternalId));
|
|
|
|
if ($normalizedId === '') {
|
|
return null;
|
|
}
|
|
|
|
return hash('sha256', trim(mb_strtolower($policyType)).'|'.$normalizedId);
|
|
}
|
|
|
|
public static function workspaceSafeSubjectExternalId(string $policyType, string $subjectKey): string
|
|
{
|
|
return hash('sha256', $policyType.'|'.$subjectKey);
|
|
}
|
|
|
|
public static function workspaceSafeSubjectExternalIdForPolicy(string $policyType, ?string $displayName = null, ?string $subjectExternalId = null): ?string
|
|
{
|
|
$identityInput = match (InventoryPolicyTypeMeta::baselineCompareIdentityStrategy($policyType)) {
|
|
'external_id' => is_string($subjectExternalId) ? trim(mb_strtolower($subjectExternalId)) : null,
|
|
default => self::fromDisplayName($displayName),
|
|
};
|
|
|
|
if (! is_string($identityInput) || $identityInput === '') {
|
|
return null;
|
|
}
|
|
|
|
return self::workspaceSafeSubjectExternalId($policyType, $identityInput);
|
|
}
|
|
}
|