## 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
81 lines
2.5 KiB
PHP
81 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Intune;
|
|
|
|
use App\Models\Tenant;
|
|
use App\Services\Graph\GraphClientInterface;
|
|
use App\Services\Graph\GraphErrorMapper;
|
|
use App\Services\Providers\MicrosoftGraphOptionsResolver;
|
|
use App\Services\Providers\ProviderConfigurationRequiredException;
|
|
use App\Support\Providers\ProviderReasonCodes;
|
|
use Throwable;
|
|
|
|
class TenantConfigService
|
|
{
|
|
public function __construct(
|
|
private readonly GraphClientInterface $graphClient,
|
|
private readonly MicrosoftGraphOptionsResolver $graphOptionsResolver,
|
|
) {}
|
|
|
|
/**
|
|
* @return array{success:bool,error_message:?string,requires_consent:bool}
|
|
*/
|
|
public function testConnectivity(Tenant $tenant): array
|
|
{
|
|
try {
|
|
$options = $this->graphOptions($tenant);
|
|
} catch (ProviderConfigurationRequiredException $exception) {
|
|
return [
|
|
'success' => false,
|
|
'error_message' => $exception->getMessage(),
|
|
'requires_consent' => $exception->reasonCode === ProviderReasonCodes::ProviderConsentMissing,
|
|
];
|
|
}
|
|
|
|
if ($options['tenant'] === null) {
|
|
return [
|
|
'success' => false,
|
|
'error_message' => 'Tenant ID is missing',
|
|
'requires_consent' => false,
|
|
];
|
|
}
|
|
|
|
try {
|
|
$response = $this->graphClient->getOrganization($options);
|
|
} catch (Throwable $throwable) {
|
|
$mapped = GraphErrorMapper::fromThrowable($throwable, ['tenant' => $options['tenant']]);
|
|
|
|
return [
|
|
'success' => false,
|
|
'error_message' => $mapped->getMessage(),
|
|
'requires_consent' => $this->requiresConsent($mapped->getMessage()),
|
|
];
|
|
}
|
|
|
|
if ($response->failed()) {
|
|
$message = $response->errors[0]['message'] ?? $response->errors[0] ?? 'Graph connectivity failed';
|
|
|
|
return [
|
|
'success' => false,
|
|
'error_message' => is_string($message) ? $message : json_encode($message),
|
|
'requires_consent' => $this->requiresConsent((string) $message),
|
|
];
|
|
}
|
|
|
|
return ['success' => true, 'error_message' => null, 'requires_consent' => false];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function graphOptions(Tenant $tenant): array
|
|
{
|
|
return $this->graphOptionsResolver->resolveForTenant($tenant);
|
|
}
|
|
|
|
private function requiresConsent(string $message): bool
|
|
{
|
|
return str_contains(strtolower($message), 'consent');
|
|
}
|
|
}
|