Skip to content

feat: #45 Space Management & Configuration — all 6 chunks#49

Open
Weegy wants to merge 5 commits intomainfrom
feature/space-management
Open

feat: #45 Space Management & Configuration — all 6 chunks#49
Weegy wants to merge 5 commits intomainfrom
feature/space-management

Conversation

@Weegy
Copy link
Copy Markdown
Contributor

@Weegy Weegy commented Mar 16, 2026

#45 Space Management & Configuration

Chunks Completed: 6/6

Chunk 1: Migration + Model Update

  • Added description (text, nullable) and default_locale (string(10), default 'en') to spaces table
  • Idempotent migration with hasColumn guard
  • Updated Space model fillable + PHPDoc

Chunk 2: DefaultSpaceSeeder + ResolveSpace Middleware

  • DefaultSpaceSeeder: firstOrCreate default space
  • DatabaseSeeder: DefaultSpaceSeeder runs first
  • ResolveSpace middleware: X-Space-Id header → session → first space → 503
  • Registered resolve-space alias in bootstrap/app.php

Chunk 3: SpaceAdminController + Routes

  • Full CRUD SpaceAdminController with space protection for delete
  • SpaceSwitcherController for session switching
  • Routes added to admin group with resolve-space middleware

Chunk 4: Vue Pages (Index, Create, Edit)

  • Index: table with current badge, edit/delete with confirm dialog
  • Create: form with auto-slugify
  • Edit: form + Settings JSON editor + AI Config collapsible section

Chunk 5: Space Switcher + Inertia Share

  • HandleInertiaRequests: shares currentSpace + spaces list (cached 60s)
  • MainLayout: SpaceSwitcher dropdown, hidden when 1 space, Spaces nav item

Chunk 6: Tests

  • SpaceAdminTest: 11 tests covering full CRUD + switcher
  • ResolveSpaceTest: 4 tests covering all resolution paths + 503

Quality Gates

  • ✅ pint: pass (515 files)
  • ✅ phpstan: pass (0 errors)
  • ✅ npm build: pass
  • ✅ tests: 15/15 pass

Notes

numen-bot added 5 commits March 16, 2026 04:49
- Add ResolveCurrentSpace middleware (request->attributes based)
- Add Request::macro('space') in AppServiceProvider
- Share currentSpace + spaces via HandleInertiaRequests
- SpaceAdminController CRUD + SpaceSwitcherController
- Vue pages: Admin/Spaces/Index, Create, Edit (tabs: General, AI Providers, Settings, Danger Zone)
- SpaceSwitcher.vue component + MainLayout integration
- DefaultSpaceSeeder + DatabaseSeeder prepend
- Refactor Space::first() -> request->space() in 6 controllers
- Fix WebhookAdminController 403 via request->space()
- phpstan.neon: ignore macro method.notFound errors
- Pint pass, PHPStan pass, npm build pass
…ption, IDOR fix, null abort

- HIGH#1: EnsureUserIsAdmin now gates entire /admin/* group unconditionally
  (allows admins and RBAC-role users; permission middleware handles per-route authz)
- HIGH#2: api_config encrypted at rest via Crypt::encryptString/decryptString in Space model;
  SpaceAdminController::edit() masks values with '***' before sending to browser;
  update() skips overwrite when all values are masked sentinels
- MEDIUM#3: SpaceAdminController::index() uses $request->attributes->get('space')
  instead of app('current_space') to match ResolveCurrentSpace binding
- MEDIUM#4: X-Space-Id header resolution restricted to admin users only (IDOR guard)
- MEDIUM#5: ResolveSpace marked @deprecated; ResolveCurrentSpace is canonical
- MEDIUM#6: ResolveCurrentSpace aborts 503 if no space can be resolved (null no longer allowed through)
- LOW#7: SpaceAdminController::destroy() wrapped in DB::transaction with lockForUpdate() to prevent TOCTOU
- LOW#8: Duplicate Space::first() fallback removed from ResolveCurrentSpace

Tests updated to reflect new 503 behavior (no-space = service unavailable) and to
seed a Space fixture where the middleware requires one.
@Weegy Weegy added the enhancement New feature or request label Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant