KoniKode · Software built with intention

KNOWLEDGE BASE

Documentation

DOCUMENTATION
CURRENT APPLICATIONClean Framework
DocumentationClean Framework

Clean Framework · DOCUMENTATION

Protect a developer-only route

Protect a developer-only route

Steps

Use application-owned middleware to authenticate and authorize before controller resolution.

// Registration fragment; $access is the composed DeveloperAccess middleware.
$router->get('/api/search', DocumentationController::class . '::search')
    ->middleware($access)
    ->name('knowledge.search');

Read the principal from RequestAttribute::PRINCIPAL, not a guessed attribute name. Then filter document permissions again before reading bodies, search, or provider context. A hidden button is not a permission check.

Verify

Anonymous API reads return 401 without document bodies. A revoked account loses access on its next protected request. See Authentication and security.

Editorial provenance

Source: resources/guides/protect-route.md. Source SHA-256: 87e22e899bba1dfbc55eb57e8438106baa7fba7a857671532115bd097648a84f.

Knowledge-base application source; editorial checkpoint 2026-10-20. See candidate status and adoption boundary.

EXPLORE FURTHER

Drag a divider or use Left and Right Arrow keys to resize. Hold Shift for larger steps. Enter hides or restores the sidebar; Home and End select its minimum or maximum width. Double-click resets the width.

Install KoniKode