TenantAtlas/apps/platform/app/Services/Providers/ProviderOperationStartGate.php
ahmido 9374260ae1 feat: add Exchange PowerShell invocation gate (#498)
## Summary
- Adds the Spec 431 Exchange PowerShell invocation gate and operation registration slice.
- Introduces trusted provider operation start handling and read-only Exchange PowerShell runner abstractions.
- Updates provider capability/readiness evaluation and coverage for Exchange PowerShell invocation safety.

## Verification
- `cd apps/platform && ./vendor/bin/sail artisan test tests/Feature/Providers/ProviderCapabilityEvaluationTest.php tests/Feature/Providers/ProviderOperationCapabilityGateTest.php tests/Feature/TenantConfiguration/Spec431ExchangePowerShellInvocationGateTest.php tests/Unit/Providers/ProviderCapabilityRegistryTest.php tests/Unit/Providers/ProviderOperationStartGateTest.php tests/Unit/Support/TenantConfiguration/Spec430ExchangePowerShellCommandAllowlistTest.php tests/Unit/Support/TenantConfiguration/Spec431ExchangePowerShellOperationRegistrationTest.php tests/Unit/Verification/ManagedEnvironmentPermissionCapabilityMappingTest.php`
- Result: 80 passed, 685 assertions.

## Product Surface / Ops
- Rendered UI surface changed: N/A.
- Filament/Livewire surface changed: N/A.
- Deployment impact: config/runtime service changes only; no migrations, queues, or assets added.

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #498
2026-07-07 15:23:29 +00:00

54 lines
1.7 KiB
PHP

<?php
namespace App\Services\Providers;
use App\Models\ManagedEnvironment;
use App\Models\ProviderConnection;
use App\Models\User;
use App\Support\Providers\ProviderReasonCodes;
final class ProviderOperationStartGate
{
public function __construct(
private readonly ProviderOperationTrustedStarter $trustedStarter,
) {}
/**
* @param array<string, mixed> $extraContext
*/
public function start(
ManagedEnvironment $tenant,
?ProviderConnection $connection,
string $operationType,
callable $dispatcher,
?User $initiator = null,
array $extraContext = [],
): ProviderOperationStartResult {
if ($this->isExchangePowerShellInvocationOperation($operationType)) {
return $this->trustedStarter->block(
tenant: $tenant,
connection: $connection,
operationType: $operationType,
reasonCode: ProviderReasonCodes::ProviderBindingUnsupported,
extensionReasonCode: 'ext.exchange_powershell_invocation_gate_required',
reasonMessage: 'Exchange PowerShell invocation must start through the invocation gate.',
initiator: $initiator,
);
}
return $this->trustedStarter->start(
tenant: $tenant,
connection: $connection,
operationType: $operationType,
dispatcher: $dispatcher,
initiator: $initiator,
extraContext: $extraContext,
);
}
private function isExchangePowerShellInvocationOperation(string $operationType): bool
{
return $operationType === 'tenant_configuration.exchange_powershell_invocation';
}
}