auth-and-authorization

Implement Laravel authentication and authorization with Sanctum, policies, and gates.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/bramato/laravel-react-plugins --skill auth-and-authorization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth-and-authorization
Source: https://github.com/bramato/laravel-react-plugins/tree/main/laravel-react/skills/auth-and-authorization
Command: npx skills add https://github.com/bramato/laravel-react-plugins --skill auth-and-authorization

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance and code examples for implementing secure authentication and fine-grained authorization within Laravel applications, ensuring only the right users can access the right resources.

Core Features & Use Cases

  • Sanctum Authentication: Covers both SPA cookie-based authentication and API token authentication for various client types.
  • Policies & Gates: Demonstrates how to define and enforce authorization rules at the model and action levels.
  • RBAC Implementation: Details strategies for role-based access control, including enum-based roles and integration with spatie/laravel-permission.
  • Frontend Integration: Shows how to share authentication status and permissions with Inertia.js frontends and perform checks there.
  • Password Resets & Verification: Integrates with Laravel Fortify for headless password reset and email verification flows.
  • Testing: Provides examples for unit and feature testing of authentication and authorization logic.

Quick Start

Implement Sanctum SPA authentication by configuring middleware and creating an authentication controller.

Frequently Asked Questions about auth-and-authorization

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

FAQPage Schema
How do I implement authentication and authorization in Laravel using Sanctum?

Laravel Sanctum provides lightweight authentication for SPAs and APIs. You can configure cookie-based authentication for single-page applications or generate API tokens for external clients to secure your application endpoints effectively.

When should I use Gates versus Policies for RBAC in Laravel?

Use Gates for action-level authorization checks like viewing an admin dashboard, and Policies for model-level authorization like updating a specific Post. Both support role-based access control to enforce fine-grained user permissions.

Can I integrate Laravel authentication with an Inertia.js frontend?

Yes, you can share authentication status and RBAC permissions with Inertia.js. This allows you to perform frontend permission checks and provide a seamless user experience without compromising application security.

Does this approach support password reset and email verification flows?

Yes, integrating with Laravel Fortify provides headless password reset and email verification flows. This ensures your application handles secure credential recovery and verifies user identities without requiring a custom frontend.

How do I test authentication and authorization logic in Laravel?

You can implement unit and feature tests for authentication and authorization logic by simulating user logins and asserting access restrictions. This ensures your Sanctum tokens, Gates, and Policies enforce security rules correctly.

Is spatie/laravel-permission compatible with this RBAC implementation?

Yes, the implementation details strategies for role-based access control including integration with spatie/laravel-permission. It also covers enum-based roles to manage user permissions and access levels effectively.