Go to file
ahmido 33a2b1a242 feat(106): Required Permissions sidebar stays on workspace nav (#129)
## Summary

Fixes the sidebar context bug where navigating to the **Required Permissions** page (`/admin/tenants/{id}/required-permissions`) would switch the sidebar from workspace navigation to tenant-scoped navigation, confusing users.

## Problem

The `EnsureFilamentTenantSelected` middleware detected a tenant ID in the URL and called `setTenant()`, which switched the entire sidebar to tenant-scoped navigation. The Required Permissions page is logically a **workspace-level** page that happens to reference a tenant — it should keep showing workspace nav.

## Changes

### Middleware (`EnsureFilamentTenantSelected.php`)
- **`isWorkspaceScopedPageWithTenant()`** — new private helper that detects workspace-scoped pages containing a tenant parameter via regex
- **Livewire referer bypass** — checks if a Livewire request originates from a workspace-scoped page and preserves workspace nav
- **`setTenant()` bypass** — skips tenant activation and `rememberLastTenantId()` for workspace-scoped pages

### Tests
- **`RequiredPermissionsSidebarTest.php`** (NEW) — 7 tests covering:
  - Workspace nav visible on required-permissions page
  - Tenant nav absent on required-permissions page
  - Direct URL access preserves workspace nav
  - 404 for non-member tenants
  - 404 for tenants without entitlement
  - Tenant pages still show tenant sidebar (regression guard)
  - Scoped tenant resolves correctly on tenant pages

### Pre-existing test fixes
- **`RequiredPermissionsEmptyStateTest`** — fixed URL assertion (dynamic `TenantResource::getUrl()` instead of hardcoded `/admin/onboarding`)
- **`RequiredPermissionsLinksTest`** — fixed URL assertion + multiline HTML `data-testid` assertion
- **`RequiredPermissionsFiltersTest`** — fixed `entra_permissions` config leak from branch 105

## Test Results

| Suite | Result |
|-------|--------|
| RequiredPermissions (26 tests) | **26 pass** (73 assertions) |
| Full regression (1571 tests) | **1562 pass**, 2 fail (pre-existing OpsUx), 7 skipped |

The 2 failures are pre-existing in `OpsUx/OperationCatalogCoverageTest` and `OpsUx/OperationSummaryKeysSpecTest` — unrelated to this feature.

## Spec Artifacts

- `specs/106-required-permissions-sidebar-context/plan.md`
- `specs/106-required-permissions-sidebar-context/tasks.md`
- `specs/106-required-permissions-sidebar-context/research.md`
- `specs/106-required-permissions-sidebar-context/data-model.md`
- `specs/106-required-permissions-sidebar-context/quickstart.md`

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #129
2026-02-22 02:42:44 +00:00
.agents/skills Baseline governance UX polish + view Infolist (#123) 2026-02-19 23:56:09 +00:00
.ai/guidelines chore: install Laravel Boost + MCP config 2026-01-20 23:36:08 +01:00
.codex Baseline governance UX polish + view Infolist (#123) 2026-02-19 23:56:09 +00:00
.gemini chore: install Laravel Boost + MCP config 2026-01-20 23:36:08 +01:00
.gitea chore: add PR and issue templates (#1) 2025-12-14 21:39:47 +00:00
.github feat(106): Required Permissions sidebar stays on workspace nav (#129) 2026-02-22 02:42:44 +00:00
.specify Baseline governance UX polish + view Infolist (#123) 2026-02-19 23:56:09 +00:00
app feat: Spec 105 — Entra Admin Roles Evidence + Findings (#128) 2026-02-22 02:37:36 +00:00
bootstrap feat(spec-080): workspace-managed tenant administration migration (#97) 2026-02-07 19:45:13 +00:00
config feat: Spec 105 — Entra Admin Roles Evidence + Findings (#128) 2026-02-22 02:37:36 +00:00
database feat: Spec 105 — Entra Admin Roles Evidence + Findings (#128) 2026-02-22 02:37:36 +00:00
docs feat: action-surface contract inspect affordance + clickable rows (#100) 2026-02-08 20:31:36 +00:00
drizzle feat: TenantPilot v1 - Complete implementation (Phases 1-12) 2025-12-12 02:27:54 +01:00
public feat: upgrade Filament to v5.2.1 (#124) 2026-02-20 12:20:42 +00:00
resources feat: Spec 105 — Entra Admin Roles Evidence + Findings (#128) 2026-02-22 02:37:36 +00:00
routes feat: Spec 105 — Entra Admin Roles Evidence + Findings (#128) 2026-02-22 02:37:36 +00:00
scripts feat(058): tenant dashboard + active-runs gating (#68) 2026-01-21 14:00:42 +00:00
spechistory feat: TenantPilot v1 - Complete implementation (Phases 1-12) 2025-12-12 02:27:54 +01:00
specs feat(106): Required Permissions sidebar stays on workspace nav (#129) 2026-02-22 02:42:44 +00:00
storage feat: TenantPilot v1 - Complete implementation (Phases 1-12) 2025-12-12 02:27:54 +01:00
tests feat: Spec 105 — Entra Admin Roles Evidence + Findings (#128) 2026-02-22 02:37:36 +00:00
.dockerignore Spec 078: Operations tenantless canonical detail (#95) 2026-02-07 09:07:26 +00:00
.editorconfig Initial commit from Specify template 2025-12-10 22:27:21 +01:00
.env.example feat: implement auth structure system panel (#77) 2026-01-27 21:49:18 +00:00
.gitattributes Initial commit from Specify template 2025-12-10 22:27:21 +01:00
.gitignore Spec 078: Operations tenantless canonical detail (#95) 2026-02-07 09:07:26 +00:00
.npmignore feat(054): finalize docs — RBAC delegated group search + Restore DB-only mapping; constitution note 2026-01-17 23:14:20 +01:00
.prettierignore 058-tenant-ui-polish (#70) 2026-01-22 00:17:23 +00:00
Agents.md Baseline governance UX polish + view Infolist (#123) 2026-02-19 23:56:09 +00:00
artisan Initial commit from Specify template 2025-12-10 22:27:21 +01:00
boost.json Baseline governance UX polish + view Infolist (#123) 2026-02-19 23:56:09 +00:00
composer.json feat: upgrade Filament to v5.2.1 (#124) 2026-02-20 12:20:42 +00:00
composer.lock feat: upgrade Filament to v5.2.1 (#124) 2026-02-20 12:20:42 +00:00
docker-compose.yml feat: unify provider connection actions and notifications (#73) 2026-01-25 01:01:37 +00:00
drizzle.config.ts feat: TenantPilot v1 - Complete implementation (Phases 1-12) 2025-12-12 02:27:54 +01:00
GEMINI.md Baseline governance UX polish + view Infolist (#123) 2026-02-19 23:56:09 +00:00
opencode.json chore: install Laravel Boost + MCP config 2026-01-20 23:36:08 +01:00
package-lock.json dev-merges/c709b36 (#3) 2025-12-21 23:15:12 +00:00
package.json feat: TenantPilot v1 - Complete implementation (Phases 1-12) 2025-12-12 02:27:54 +01:00
phpunit.pgsql.xml Spec 094: Assignment ops observability hardening (#113) 2026-02-15 14:08:14 +00:00
phpunit.xml 085-tenant-operate-hub (#103) 2026-02-11 13:02:03 +00:00
PROJECT_SUMMARY.md chore/docs-constitution-v1.1.0 (#40) 2026-01-07 13:43:21 +00:00
README.md feat/032-backup-scheduling-mvp (#36) 2026-01-07 01:12:12 +00:00
vite.config.js dev-merges/c709b36 (#3) 2025-12-21 23:15:12 +00:00

Laravel Logo

Build Status Total Downloads Latest Stable Version License

TenantPilot setup

  • Local dev (Sail-first):
    • Start stack: ./vendor/bin/sail up -d
    • Init DB: ./vendor/bin/sail artisan migrate --seed
    • Tests: ./vendor/bin/sail artisan test
    • Policy sync: ./vendor/bin/sail artisan intune:sync-policies
  • Filament admin: /admin (seed user test@example.com, set password via factory or artisan tinker).
  • Microsoft Graph (Intune) env vars:
    • GRAPH_TENANT_ID
    • GRAPH_CLIENT_ID
    • GRAPH_CLIENT_SECRET
    • GRAPH_SCOPE (default https://graph.microsoft.com/.default)
    • Without these, the NullGraphClient runs in dry mode (no Graph calls).
    • Required API Permissions: See docs/PERMISSIONS.md for complete list
      • Missing permissions? Scope tags will show as "Unknown (ID: X)" - add DeviceManagementRBAC.Read.All
  • Deployment (Dokploy, staging → production):
    • Containerized deploy; ensure Postgres + Redis are provisioned (see docker-compose.yml for local baseline).
    • Run migrations on staging first, validate backup/restore flows, then promote to production.
    • Ensure queue workers are running for jobs (e.g., policy sync) after deploy.
    • Keep secrets/env in Dokploy, never in code.

Bulk operations (Feature 005)

  • Bulk actions are available in Filament resource tables (Policies, Policy Versions, Backup Sets, Restore Runs).
  • Destructive operations require type-to-confirm at higher thresholds (e.g. DELETE).
  • Long-running bulk ops are queued; the bottom-right progress widget polls for active runs.

Troubleshooting

  • Progress stuck on “Queued…” usually means the queue worker is not running (or not processing the queue you expect).
    • Prefer using the Sail/Docker worker (see docker-compose.yml) rather than starting an additional local php artisan queue:work.
    • Check worker status/logs: ./vendor/bin/sail ps and ./vendor/bin/sail logs -f queue.
  • Exit code 137 for queue:work typically means the process was killed (often OOM). Increase Docker memory/limits or run the worker inside the container.

Configuration

  • TENANTPILOT_BULK_CHUNK_SIZE (default 10): job refresh/progress chunk size.
  • TENANTPILOT_BULK_POLL_INTERVAL_SECONDS (default 3): Livewire polling interval for the progress widget (clamped to 110s).

Intune RBAC Onboarding Wizard

  • Entry point: Tenant detail in Filament (Setup Intune RBAC in the ⋯ ActionGroup). Visible only for active tenants with app_client_id.
  • Flow (synchronous, delegated):
    1. Configure Role (default Policy/Profile Manager), Scope (global or scope group), Group mode (create default TenantPilot-Intune-RBAC or pick existing security-enabled group). Review planned changes.
    2. Delegated admin login (short-lived token, not stored in DB/cache).
    3. Execute: resolve service principal, ensure/validate security group, ensure membership, ensure/create/patch Intune role assignment; persists IDs on tenant for idempotency; no queue.
    4. Post-verify: forces fresh token, runs canary reads (deviceConfigurations/deviceCompliancePolicies; CA canary only if feature enabled), updates health and warnings (scope-limited, CA disabled, manual assignment required).
  • Safety/notes: least-privilege default, idempotent reruns, “already exists” treated as success. If service principal missing, run Admin consent first. Scope-limited setups may yield partial inventory/restore; warnings are surfaced in UI and health panel.

Graph Contract Registry & Drift Guard

  • Registry: config/graph_contracts.php defines per-type contracts (resource paths, allowed $select/$expand, @odata.type family, create/update methods, id field, hydration).
  • Client behavior:
    • Sanitizes $select/$expand to allowed fields; logs warnings on trim.
    • Derived @odata.type values within the family are accepted for preview/restore routing.
    • Capability fallback: on 400s related to select/expand, retries without those clauses and surfaces warnings.
  • Drift check: php artisan graph:contract:check [--tenant=] runs lightweight probes against contract endpoints to detect capability/shape issues; useful in staging/CI (prod optional).
  • If Graph returns capability errors, TenantPilot downgrades safely, records warnings/audit entries, and avoids breaking preview/restore flows.

Policy Settings Display

  • Policy detail pages render normalized settings instead of raw JSON:
    • OMA-URI/custom policies → path/value table
    • Settings Catalog → flattened key/value entries
    • Standard objects → labeled key/value view with metadata filtered
  • Version detail pages show both pretty-printed JSON and normalized settings.
  • Warnings surface malformed snapshots or @odata.type mismatches before restore.

Policy JSON Viewer (Feature 002)

  • Location: Policy View pages (/admin/policies/{record})
  • Capability: Pretty-printed JSON snapshot viewer with copy-to-clipboard
  • Settings Catalog Enhancement: Dual-view tabs (Settings table + JSON viewer) for Settings Catalog policies
  • Features:
    • Copy JSON to clipboard with success message
    • Large payload detection (>500 KB) with warning badge and auto-collapse
    • Dark mode support integrated with Filament design system
    • Browser native search (Cmd+F / Ctrl+F) for finding specific keys or values
    • Scrollable container with max height to prevent page overflow
  • Usage: See specs/002-filament-json/quickstart.md for detailed examples and configuration
  • Performance: Optimized for payloads up to 1 MB; auto-collapse improves initial render for large snapshots

About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

Laravel is accessible, powerful, and provides tools required for large, robust applications.

Learning Laravel

Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out Laravel Learn, where you will be guided through building a modern Laravel application.

If you don't feel like reading, Laracasts can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Partners program.

Premium Partners

Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.

License

The Laravel framework is open-sourced software licensed under the MIT license.