security-hardening

Configure Laravel Sanctum, secure sessions, and policy-based RBAC for applications.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/majedsiefalnasr/bunyan-app-cursor --skill security-hardening-majedsiefalnasr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: security-hardening
Source: https://github.com/majedsiefalnasr/bunyan-app-cursor/tree/main/.agents/skills/security-hardening
Command: npx skills add https://github.com/majedsiefalnasr/bunyan-app-cursor --skill security-hardening-majedsiefalnasr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill guides developers in hardening Laravel applications by implementing robust authentication, session security, and RBAC controls to reduce exposure to common threats.

Core Features & Use Cases

  • Token-based authentication setup: configure Laravel Sanctum for SPA and API access with appropriate token lifetimes.
  • Session & request security: enforce secure, HttpOnly, and SameSite cookies, plus CSRF protection and CSP policies.
  • RBAC & authorization: implement policy patterns and middleware to restrict access according to roles and ownership.

Quick Start

Configure Sanctum for your Laravel project, enable secure sessions, and apply a policy-based RBAC approach across API routes.

Frequently Asked Questions about security-hardening

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

FAQPage Schema
How do I configure Laravel Sanctum for SPA and API token authentication?

Laravel Sanctum provides token-based authentication for SPAs and APIs by issuing API tokens with defined lifetimes. It enables secure stateless API requests and stateful SPA sessions through configured middleware.

What is the best way to implement RBAC authorization in Laravel?

RBAC authorization in Laravel is implemented using policy patterns and middleware stacking to restrict route access. This enforces role-based and ownership checks across application endpoints.

How do I enforce secure session handling with HttpOnly and SameSite cookies in Laravel?

Secure session handling in Laravel involves configuring cookies with secure, HttpOnly, and SameSite attributes. This prevents client-side script access and mitigates cross-site request forgery risks.

Does this Laravel security hardening approach apply to both web and API routes?

Yes, this security hardening approach applies to both web and API routes by implementing CSRF protection, CSP policies, and rate limiting. It covers Sanctum token-based contexts and standard session handling.

How do I add CSP and CSRF safeguards across Laravel routes?

To add CSP and CSRF safeguards across Laravel routes, apply middleware stacking to enforce Content Security Policies and verify CSRF tokens. This protects against cross-site scripting and request forgery attacks.

Why do I need strict file upload validation in Laravel applications?

Strict file upload validation in Laravel prevents malicious file execution by checking MIME types and sizes. This reduces exposure to common threats associated with untrusted user uploads.