Search by

marko / security

markshust

Security middleware for Marko Framework -- CSRF protection and security headers

Package info

github.com/marko-php/marko-security

Type:marko-module

pkg:composer/marko/security

Statistics

Installs: 295

Dependents: 1

Suggesters: 0

Stars: 0

0.11.0 2026-10-06 15:09 UTC

README

CSRF protection and security headers middleware -- secure your routes with drop-in middleware. For CORS, use marko/cors.

Installation

composer require marko/security

Quick Example

CsrfMiddleware and SecurityHeadersMiddleware are registered globally, so every state-changing route is protected and every response carries security headers. Opt a route out explicitly:

use Marko\Routing\Attributes\Post;
use Marko\Routing\Attributes\WithoutMiddleware;
use Marko\Security\Middleware\CsrfMiddleware;

class WebhookController
{
    #[Post('/webhooks/stripe')]
    #[WithoutMiddleware(CsrfMiddleware::class)]
    public function receive(): Response
    {
        return new Response('Received');
    }
}

Documentation

Full usage, API reference, and examples: marko/security