Implements 064-auth-structure (Auth Structure v1.0): Adds platform_users + PlatformUser identity (factory + seeder) for platform operators Introduces platform auth guard/provider in auth.php Adds a dedicated Filament v5 System panel at system using guard platform (custom login + dashboard) Enforces strict cross-scope isolation between /admin and system (deny-as-404) Adds platform capability gating (platform.access_system_panel, platform.use_break_glass) + gates in AuthServiceProvider Implements audited break-glass mode (enter/exit/expire), banner via render hook, feature flag + TTL config Removes legacy users.is_platform_superadmin runtime usage and adds an architecture test to prevent regressions Updates tenant membership pivot usage where needed (tenant_memberships) Testing: vendor/bin/sail artisan test --compact tests/Feature/Auth (28 passed) vendor/bin/sail bin pint --dirty Notes: Filament v5 / Livewire v4 compatible. Panel providers registered in providers.php. Destructive actions use ->action(...) + ->requiresConfirmation() where applicable. Co-authored-by: Ahmed Darrazi <ahmeddarrazi@MacBookPro.fritz.box> Reviewed-on: #77
6.4 KiB
Tasks: Auth Structure v1.0
Feature: 064-auth-structure
Plan: plan.md
Specification: spec.md
This document breaks down the implementation of the Auth Structure feature into actionable, dependency-ordered tasks.
Phase 1: Foundational Setup (Prerequisites)
These tasks create the core data structure and must be completed before any auth logic is built.
- T001 Create migration for
platform_userstable indatabase/migrations/ - T002 Create
PlatformUsermodel inapp/Models/PlatformUser.php - T003 Create
PlatformUserFactoryindatabase/factories/PlatformUserFactory.php
Phase 2: Core Authentication Configuration
These tasks configure Laravel's authentication system to recognize the new user type and guard.
- T004 Define
platformguard andplatform_usersprovider inconfig/auth.php - T005 [P] Create
PlatformUserSeederto seed an initial operator account indatabase/seeders/PlatformUserSeeder.php - T006 [P] Update
DatabaseSeederto call thePlatformUserSeederindatabase/seeders/DatabaseSeeder.php
Phase 3: User Story 2 - Platform Panel Implementation (P1)
Goal: A platform operator can log in to a new, separate /system panel.
Independent Test: A seeded user can authenticate at /system/login and access a system dashboard, while being denied access to /admin/t/* routes.
- T007 [US2] Create
SystemPanelProviderinapp/Providers/Filament/SystemPanelProvider.phpand configure it to use theplatformauth guard (path/system). - T008 [US2] Register
SystemPanelProviderinbootstrap/providers.php - T009 [US2] Create Filament v5 System login page at
app/Filament/System/Pages/Auth/Login.php(local email+password) and wire it viaSystemPanelProvider->login(...). - T010 [US2] Create a basic dashboard page for the System Panel in
app/Filament/System/Pages/Dashboard.php - T011 [US2] Create
SystemPanelAuthTest.phpto verify platform user login and logout intests/Feature/Auth/SystemPanelAuthTest.php - T011b [US2] Implement audit logging for platform login attempts (success and failure) and add assertions to
SystemPanelAuthTest.php. - T018b [US2] Enforce minimum capability
platform.access_system_panelfor any authenticated platform session to use/system(otherwise deny-as-not-found / 404). Depends on T017 + T018. Add a small test case toSystemPanelAuthTest.php.
Phase 4: User Story 1 - Admin Panel Isolation & Cross-Scope Enforcement (P1)
Goal: A tenant admin can log in via Entra ID and cannot access the system panel.
Independent Test: An Entra-authenticated user can access /admin/t/{tenant} but receives a 404 upon visiting /system.
- T012 [US1] Create
EnsureCorrectGuardmiddleware to enforce 404s on cross-panel access inapp/Http/Middleware/EnsureCorrectGuard.php - T013 [US1] Apply
EnsureCorrectGuardto BOTH panels deterministically (preferred: panel middleware stack in each PanelProvider; acceptable: explicit route-group middleware in routes/web.php). Cross-scope MUST return 404. - T014 [US1] [P] Verify
/admin/loginis Entra-only: no password inputs rendered and no break-glass link/banner appears in the admin login surface (assert via feature test or DOM assertions). - T015 [US1] Create
CrossScopeAccessTest.phpto verify 404 responses for both tenant->system and platform->admin access attempts intests/Feature/Auth/CrossScopeAccessTest.php - T016 [US1] Create
AdminPanelAuthTest.phpto confirm Entra-only login flow works as expected intests/Feature/Auth/AdminPanelAuthTest.php
Phase 5: User Story 3 - Break-glass Mode (P2)
Goal: A privileged platform operator can enter a temporary, audited "break-glass" session. Independent Test: An operator with the correct capability can start the session, see a banner, and have the session expire or exit, with all events being logged.
- T017 [US3] Define platform capabilities (e.g.,
platform.access_system_panel,platform.use_break_glass) inapp/Support/Auth/PlatformCapabilities.php - T018 [US3] Register gates for platform capabilities in
app/Providers/AuthServiceProvider.php(do not introduce a new provider just for this). - T019 [US3] Implement the session logic for starting, checking, and clearing the break-glass state (including capturing an operator-provided reason).
- T020 [US3] [P] Create the
break-glass-banner.blade.phpview component inresources/views/filament/system/components/ - T021 [US3] Add the "Enter break-glass mode"
Actionto a page in the System Panel, visible only to users with theplatform.use_break_glasscapability, and include->requiresConfirmation(). - T022 [US3] Register a render hook in
SystemPanelProviderto display the banner when in break-glass mode. - T023 [US3] Implement
AuditLogentries for break-glass state changes (enter, exit, expire). - T024 [US3] Create
BreakGlassModeTest.phpto test the full lifecycle of the break-glass feature intests/Feature/Auth/BreakGlassModeTest.php
Phase 6: Deprecation & Polish
Final checks, cleanup, and architectural enforcement.
- T025 [P] Create
IsPlatformSuperadminDeprecationTest.phpas an architecture test to fail ifusers.is_platform_superadminis used intests/Deprecation/ - T026 Run formatting with
./vendor/bin/sail bin pint --dirtyand keep the working tree clean. - T027 [P] Add/verify
BREAK_GLASS_ENABLEDandBREAK_GLASS_TTL_MINUTESin.env.example(required). Optionally document in README.md.
Dependencies & Implementation Strategy
- MVP: The MVP consists of completing Phase 1, 2, 3, and 4. This delivers the core value of two separate, isolated authentication panels.
- Dependencies:
Phase 3 (US2)andPhase 4 (US1)can be developed in parallel afterPhase 2is complete. However, the final cross-scope tests (T015) depend on both panels being functional.Phase 5 (US3)is strictly dependent on the completion ofPhase 3 (US2).T018bdepends onT017+T018(capability definitions + gate registration).
- Parallel Execution: Within phases, tasks marked with
[P]can be worked on concurrently. For example, after the migration is created (T001), the Model (T002) and Factory (T003) can be created in parallel.
This structure allows for incremental delivery. The core platform panel (US2) can be delivered first, followed by the admin panel isolation (US1) and finally the break-glass enhancement (US3).