## Summary <!-- Kurz: Was ändert sich und warum? --> ## Spec-Driven Development (SDD) - [ ] Es gibt eine Spec unter `specs/<NNN>-<feature>/` - [ ] Enthaltene Dateien: `plan.md`, `tasks.md`, `spec.md` - [ ] Spec beschreibt Verhalten/Acceptance Criteria (nicht nur Implementation) - [ ] Wenn sich Anforderungen während der Umsetzung geändert haben: Spec/Plan/Tasks wurden aktualisiert ## Implementation - [ ] Implementierung entspricht der Spec - [ ] Edge cases / Fehlerfälle berücksichtigt - [ ] Keine unbeabsichtigten Änderungen außerhalb des Scopes ## Tests - [ ] Tests ergänzt/aktualisiert (Pest/PHPUnit) - [ ] Relevante Tests lokal ausgeführt (`./vendor/bin/sail artisan test` oder `php artisan test`) ## Migration / Config / Ops (falls relevant) - [ ] Migration(en) enthalten und getestet - [ ] Rollback bedacht (rückwärts kompatibel, sichere Migration) - [ ] Neue Env Vars dokumentiert (`.env.example` / Doku) - [ ] Queue/cron/storage Auswirkungen geprüft ## UI (Filament/Livewire) (falls relevant) - [ ] UI-Flows geprüft - [ ] Screenshots/Notizen hinzugefügt ## Notes <!-- Links, Screenshots, Follow-ups, offene Punkte --> Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #4
5.8 KiB
5.8 KiB
Microsoft Graph API Permissions
This document lists all required Microsoft Graph API permissions for TenantPilot to function correctly.
Required Permissions
The Azure AD / Entra ID App Registration used by TenantPilot requires the following Application Permissions (not Delegated):
Core Policy Management (Required)
DeviceManagementConfiguration.Read.All- Read Intune device configuration policiesDeviceManagementConfiguration.ReadWrite.All- Write/restore Intune policiesDeviceManagementApps.Read.All- Read app configuration policiesDeviceManagementApps.ReadWrite.All- Write app policies
Scope Tags (Feature 004 - Required for Phase 3)
DeviceManagementRBAC.Read.All- Read scope tags and RBAC settings- Purpose: Resolve scope tag IDs to display names (e.g., "0" → "Default")
- Missing: Backup items will show "Unknown (ID: 0)" instead of scope tag names
- Impact: Metadata display only - backups still work without this permission
Group Resolution (Feature 004 - Required for Phase 2)
Group.Read.All- Resolve group IDs to names for assignmentsDirectory.Read.All- Batch resolve directory objects (groups, users, devices)
How to Add Permissions
Azure Portal (Entra ID)
- Go to Azure Portal → Entra ID (Azure Active Directory)
- Navigate to App registrations → Select your TenantPilot app
- Click API permissions in the left menu
- Click + Add a permission
- Select Microsoft Graph → Application permissions
- Search for and select the required permissions:
DeviceManagementRBAC.Read.All- (Add others as needed)
- Click Add permissions
- IMPORTANT: Click Grant admin consent for [Your Organization]
- ⚠️ Without admin consent, the permissions won't be active!
PowerShell (Alternative)
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "Application.ReadWrite.All"
# Get your app registration
$appId = "YOUR-APP-CLIENT-ID"
$app = Get-MgApplication -Filter "appId eq '$appId'"
# Add DeviceManagementRBAC.Read.All permission
$graphServicePrincipal = Get-MgServicePrincipal -Filter "appId eq '00000003-0000-0000-c000-000000000000'"
$rbacPermission = $graphServicePrincipal.AppRoles | Where-Object {$_.Value -eq "DeviceManagementRBAC.Read.All"}
$requiredResourceAccess = @{
ResourceAppId = "00000003-0000-0000-c000-000000000000"
ResourceAccess = @(
@{
Id = $rbacPermission.Id
Type = "Role"
}
)
}
Update-MgApplication -ApplicationId $app.Id -RequiredResourceAccess $requiredResourceAccess
# Grant admin consent
# (Must be done manually or via Graph API with RoleManagement.ReadWrite.Directory scope)
Verification
After adding permissions and granting admin consent:
- Go to App registrations → Your app → API permissions
- Verify status shows Granted for [Your Organization] with a green checkmark ✅
- Clear cache in TenantPilot:
php artisan cache:clear - Test scope tag resolution:
Expected output:php artisan tinker >>> use App\Services\Graph\ScopeTagResolver; >>> use App\Models\Tenant; >>> $tenant = Tenant::first(); >>> $resolver = app(ScopeTagResolver::class); >>> $tags = $resolver->resolve(['0'], $tenant); >>> dd($tags);[ [ "id" => "0", "displayName" => "Default" ] ]
Troubleshooting
Error: "Application is not authorized to perform this operation"
Symptoms:
- Backup items show "Unknown (ID: 0)" for scope tags
- Logs contain:
Application must have one of the following scopes: DeviceManagementRBAC.Read.All
Solution:
- Add
DeviceManagementRBAC.Read.Allpermission (see above) - Grant admin consent (critical step!)
- Wait 5-10 minutes for Azure to propagate permissions
- Clear cache:
php artisan cache:clear - Test again
Error: "Insufficient privileges to complete the operation"
Cause: The user account used to grant admin consent doesn't have sufficient permissions.
Solution:
- Use an account with Global Administrator or Privileged Role Administrator role
- Or have the IT admin grant consent for the organization
Permissions showing but still getting 403
Possible causes:
- Admin consent not granted (click the button!)
- Permissions not yet propagated (wait 5-10 minutes)
- Wrong tenant (check tenant ID in app config)
- Cached token needs refresh (clear cache + restart)
Feature Impact Matrix
| Feature | Required Permissions | Without Permission | Impact Level |
|---|---|---|---|
| Basic Policy Backup | DeviceManagementConfiguration.Read.All |
Cannot backup | 🔴 Critical |
| Policy Restore | DeviceManagementConfiguration.ReadWrite.All |
Cannot restore | 🔴 Critical |
| Scope Tag Names (004) | DeviceManagementRBAC.Read.All |
Shows "Unknown (ID: X)" | 🟡 Medium |
| Assignment Names (004) | Group.Read.All + Directory.Read.All |
Shows group IDs only | 🟡 Medium |
| Group Mapping (004) | Group.Read.All |
Manual ID mapping required | 🟡 Medium |
Security Notes
- All permissions are Application Permissions (app-level, not user-level)
- Requires admin consent from Global Administrator
- Use least privilege principle: Only add permissions for features you use
- Consider creating separate app registrations for different environments (dev/staging/prod)
- Rotate client secrets regularly (recommended: every 6 months)