superpowers-sage:acorn-middleware

Protect Acorn HTTP routes with JWT authentication and role checks.

13|Updated Mar 19, 2026
One-click install
npx skills add https://github.com/hekivo/superpowers-sage --skill superpowers-sage-acorn-middleware-hekivo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: superpowers-sage:acorn-middleware
Source: https://github.com/hekivo/superpowers-sage/tree/main/skills/acorn-middleware
Command: npx skills add https://github.com/hekivo/superpowers-sage --skill superpowers-sage-acorn-middleware-hekivo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill solves the problem of protecting Acorn (Sage/Bedrock) HTTP routes with reliable authentication and authorization while ensuring WordPress-native functions work correctly inside Laravel-style middleware.

Core Features & Use Cases

  • JWT authentication & token validation: Enforce stateless access control using Bearer tokens, including access vs refresh token handling.
  • Role/guard-based authorization: Apply custom guards and role checks before controllers run, returning JSON 401/403 responses.
  • Request filtering & operational middleware: Add deterministic request preprocessing like throttling, JSON response enforcement, and CORS handling, with clear boundaries for what middleware can and cannot intercept.

Quick Start

Create an Acorn middleware named EnsureJsonResponse, register it in app/Http/Kernel.php for the appropriate middleware group or alias, then apply it to your routes so API requests return consistent JSON and protected endpoints enforce JWT and role checks.

Frequently Asked Questions about superpowers-sage:acorn-middleware

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add JWT authentication to Acorn routes in WordPress?

JWT authentication for Acorn routes is implemented using Bearer token validation within Acorn HTTP middleware. You need to configure a JWT_SECRET environment variable and register auth middleware in your Acorn HTTP Kernel to enforce stateless access control on protected endpoints.

How do I set up role-based authorization for Sage or Bedrock custom routes?

Role-based authorization for Sage and Bedrock routes is handled by applying custom guards and role checks within Acorn middleware before controllers execute. The middleware verifies user roles and capabilities, automatically returning JSON 401 or 403 responses when authorization fails.

Can I use Laravel-style middleware for rate limiting in WordPress Acorn?

Rate limiting in Acorn is achieved by applying request filtering middleware within Acorn route pipelines. You register throttling middleware in your HTTP Kernel to deterministically preprocess requests and control traffic volume, explicitly avoiding native WordPress REST paths.

Does Acorn middleware work with native WordPress functions during authentication?

Acorn middleware supports native WordPress functions during authentication by requiring wp_set_current_user to be called within the auth middleware. This ensures WordPress user functions operate correctly inside Laravel-style middleware pipelines for JWT and guard checks.

What's the best way to enforce JSON responses on protected Acorn API endpoints?

Enforcing JSON responses on Acorn API endpoints is done by creating an EnsureJsonResponse middleware and registering it in your HTTP Kernel. This operational middleware intercepts requests within the Acorn route pipeline to guarantee consistent JSON formatting and proper HTTP status codes.

Why does my Acorn route middleware not intercept WordPress admin or REST requests?

Acorn route middleware explicitly avoids intercepting native WordPress admin, template, and REST paths. It is designed exclusively for Acorn-registered HTTP routes, meaning standard WordPress requests bypass this middleware pipeline by design.