3.6 KiB
3.6 KiB
Research — Remove Legacy Tenant Graph Options
Goal
Remove usage of the deprecated tenant-based Graph options accessor ($tenant->graphOptions() / Tenant::graphOptions()) and make provider-based resolution (ProviderConnectionResolver + ProviderGateway) the single source of truth for Microsoft Graph configuration.
Decisions
Decision: Provider connection is canonical for Graph options
- Chosen: Resolve
ProviderConnectionviaApp\Services\Providers\ProviderConnectionResolver::resolveDefault($tenant, 'microsoft'), then derive options viaApp\Services\Providers\ProviderGateway::graphOptions($connection, $overrides). - Rationale: Existing services already follow this path (e.g. onboarding/health); it centralizes credential storage and validation.
- Alternatives considered:
- Keep reading tenant columns (
Tenant.app_client_id/Tenant.app_client_secret) as fallback — rejected (explicitly forbidden; introduces mixed credential sources).
- Keep reading tenant columns (
Decision: Kill-switch behavior for Tenant::graphOptions()
- Chosen: Keep method for now, but make it throw a clear exception (fail-fast).
- Rationale: Ensures any missed call site fails deterministically in CI/runtime.
- Alternatives considered:
- Delete method outright — rejected (higher risk / more disruptive API break).
Decision: Guardrail scope and matching rules
- Chosen: Add a CI guard test that scans
app/only for these forbidden patterns:\$tenant->graphOptions(Tenant::graphOptions(
- Rationale: Matches the agreed scope and avoids false positives on unrelated
graphOptions(...)methods (e.g.ProviderGateway::graphOptions). - Alternatives considered:
- Scan for all
->graphOptions(— rejected (would flag many legitimate methods). - Scan
tests/too — rejected (would create noisy failures during refactors).
- Scan for all
Current Code Findings (Call Sites)
Deprecated tenant accessor call sites (must be removed)
These are current app/ references to $tenant->graphOptions():
app/Services/AssignmentRestoreService.phpapp/Services/AssignmentBackupService.phpapp/Services/Intune/RestoreRiskChecker.phpapp/Services/Intune/TenantPermissionService.phpapp/Services/Intune/VersionService.phpapp/Services/Intune/FoundationMappingService.phpapp/Services/Intune/PolicyCaptureOrchestrator.phpapp/Services/Intune/FoundationSnapshotService.phpapp/Services/Intune/TenantConfigService.php(wraps + returns$tenant->graphOptions())app/Services/Intune/ConfigurationPolicyTemplateResolver.phpapp/Services/Directory/EntraGroupSyncService.phpapp/Services/Directory/RoleDefinitionsSyncService.phpapp/Services/Graph/AssignmentFilterResolver.php
Canonical provider-based examples to copy
app/Services/Intune/RbacOnboardingService.phpapp/Services/Intune/RbacHealthService.phpapp/Services/Intune/RestoreService.phpapp/Services/Intune/PolicySnapshotService.php
Source of legacy accessor
app/Models/Tenant.phpdefines the deprecatedgraphOptions()method.
Recommended Refactor Pattern
$resolution = $this->providerConnections()->resolveDefault($tenant, 'microsoft');
if (! $resolution->resolved || ! $resolution->connection instanceof ProviderConnection) {
// Fail fast with actionable reason.
}
$connection = $resolution->connection;
$graphOptions = $this->providerGateway()->graphOptions($connection, $overrides);
Notes / Non-goals
- No database schema changes (tenant credential columns stay for now).
- No changes to Graph contract registry (
config/graph_contracts.php) are required for this feature; this work changes configuration sourcing only.