Gate dashboard API routes with guard-aware route permissions - #26
Merged
AbdelrhmanSaid merged 2 commits intoAug 27, 2026
Merged
Conversation
Apply the RoutePermission middleware to the dashboard API route group and resolve the guard from the route's auth middleware instead of assuming the session guard: - route_allowed()/url_allowed() now accept a nullable guard and guess it from the route's auth middleware (falling back to admins) when omitted. - Add a route_guard() helper to resolve the guard a route authenticates against, shared by route_allowed() and permissions:sync. - permissions:sync stamps permissions with the provider's first configured guard so guards sharing a provider (session + API) share one permission row instead of duplicating it per guard. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GxRW8HBNUEzmPKPmGpxWQL
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GxRW8HBNUEzmPKPmGpxWQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dashboard API routes were only authenticated (
auth:admins-api), never authorized — any admin, regardless of role, could reach every dashboard API endpoint. This PR applies theRoutePermissiongate to the dashboard API route group and makes the permission machinery guard-aware so it works beyond the sessionadminsguard.Application.phpappliesRoutePermissionto theroutes/api/dashboard.phpgroup, mirroring the webdashboardmiddleware group.route_allowed()/url_allowed()now take?string $guard = null; when omitted, the guard is guessed from the route'sauthmiddleware via the newroute_guard()helper (falling back toadmins). Passing a guard explicitly still overrides, so existing callers (e.g. the sidebar) are unaffected.permissions:syncstamps permissions with the guard provider's first configured guard, so guards sharing a provider (sessionadmins+admins-api) share one permission row instead of syncing a dead per-guard duplicate.foundation/middleware.md,foundation/helpers.md): API gating, guard guessing, and the convention of aliasing API routes to their web permission withusePermission().Consumer impact
Apps registering dashboard API routes should opt public/auth/profile endpoints out with
withoutMiddleware(RoutePermission::class)and alias gated endpoints to their web permission withusePermission(). Companion change:redot-src/dashboard#claude/api-route-permissions-gating-wr55ny.Testing
route_allowed()string form), denial without a grant, andpermissions:syncdeduplicating a permission shared across guards.🤖 Generated with Claude Code
https://claude.ai/code/session_01GxRW8HBNUEzmPKPmGpxWQL
Generated by Claude Code