Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

laravel-auth

БесплатноБез исполняемых скриптовНе проверен

Use when implementing user authentication, API tokens, social login, or authorization in Laravel 13.

Fusengineот Fusengine★ 36 звёзд на GitHub8 установок в других каталогах

Об этом скилле

Covers the Laravel 13 authentication and authorization ecosystem: Sanctum (API tokens, SPA auth), Passport (OAuth2 server), Fortify (headless custom-UI auth), Socialite (social login), starter kits, policies and gates, email verification, password reset, session management, CSRF / PreventRequestForgery, encryption, and hashing. Includes FuseCore modular- project integration patterns for auth (User module, cross-module authorization via policies).

Laravel Authentication & Authorization

Agent Workflow (MANDATORY)

Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:

  1. fuse-ai-pilot:explore-codebase - Check existing auth setup, guards, policies
  2. fuse-ai-pilot:research-expert - Verify latest Laravel 13 auth docs via Context7
  3. mcp__context7__query-docs - Query specific patterns (Sanctum, Passport, etc.)

After implementation, run fuse-ai-pilot:sniper for validation.


Overview

Laravel provides a complete authentication and authorization ecosystem. Choose based on your needs:

Package Best For Complexity
Starter Kits New projects, quick setup Low
Sanctum API tokens, SPA auth Low
Fortify Custom UI, headless backend Medium
Passport OAuth2 server, third-party access High
Socialite Social login (Google, GitHub) Low

Critical Rules

  1. Use policies for model authorization - Not inline if checks
  2. Always hash passwords - Hash::make() or 'hashed' cast
  3. Regenerate session after login - Prevents fixation attacks
  4. Use HTTPS in production - Required for secure cookies
  5. Define token abilities - Principle of least privilege

Architecture

app/
├── Http/
│   ├── Controllers/
│   │   └── Auth/              ← Auth controllers (if manual)
│   └── Middleware/
│       └── Authenticate.php   ← Redirects unauthenticated
├── Models/
│   └── User.php               ← HasApiTokens trait (Sanctum)
├── Policies/                  ← Authorization policies
│   └── PostPolicy.php
├── Providers/
│   └── AppServiceProvider.php ← Gate definitions
└── Actions/
    └── Fortify/               ← Fortify actions (if used)
        ├── CreateNewUser.php
        └── ResetUserPassword.php

config/
├── auth.php                   ← Guards & providers
├── sanctum.php                ← API token config
└── fortify.php                ← Fortify features

FuseCore Integration

When working in a FuseCore project, authentication follows the modular structure:

FuseCore/
├── Core/                      # Infrastructure (priority 0)
│   └── App/Contracts/
│       └── AuthServiceInterface.php  ← Auth contract
│
├── User/                      # Auth module (existing)
│   ├── App/
│   │   ├── Models/User.php    ← HasApiTokens trait
│   │   ├── Http/
│   │   │   ├── Controllers/
│   │   │   │   ├── AuthController.php
│   │   │   │   └── TokenController.php
│   │   │   ├── Requests/
│   │   │   │   ├── LoginRequest.php
│   │   │   │   └── RegisterRequest.php
│   │   │   └── Resources/UserResource.php
│   │   ├── Policies/UserPolicy.php
│   │   └── Services/AuthService.php
│   ├── Config/
│   │   └── sanctum.php        ← Sanctum config (module-level)
│   ├── Database/Migrations/
│   ├── Routes/api.php         ← Auth routes
│   └── module.json            # dependencies: []
│
└── {YourModule}/              # Depends on User module
    ├── App/Policies/          ← Module-specific policies
    └── module.json            # dependencies: ["User"]

FuseCore Auth Checklist

  • Auth code in /FuseCore/User/ module
  • Policies in module's /App/Policies/
  • Auth routes in /FuseCore/User/Routes/api.php
  • Sanctum config in /FuseCore/User/Config/sanctum.php
  • Declare "User" dependency in other modules' module.json
  • Use auth:sanctum middleware in module routes

Cross-Module Authorization

// In FuseCore/{Module}/Routes/api.php
Route::middleware(['api', 'auth:sanctum'])->group(function () {
    Route::apiResource('posts', PostController::class);
});

// In FuseCore/{Module}/App/Http/Controllers/PostController.php
public function update(UpdatePostRequest $request, Post $post)
{
    $this->authorize('update', $post);  // Uses PostPolicy
    // ...
}

→ See fusecore skill for complete module patterns.


Decision Guide

Authentication Method

Need auth scaffolding? → Starter Kit
├── Yes → Use React/Vue/Livewire starter kit
└── No → Building custom frontend?
    ├── Yes → Use Fortify (headless)
    └── No → API only?
        ├── Yes → Sanctum (tokens)
        └── No → Session-based

Token Type

Third-party apps need access? → Passport (OAuth2)
├── No → Mobile app?
│   ├── Yes → Sanctum API tokens
│   └── No → SPA on same domain?
│       ├── Yes → Sanctum SPA auth (cookies)
│       └── No → Sanctum API tokens
Полный SKILL.md на GitHub

Установить laravel-auth в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/authentication.mdreferences/authorization.mdreferences/csrf.mdreferences/encryption.mdreferences/fortify.mdreferences/hashing.mdreferences/passport.mdreferences/passwords.mdreferences/sanctum.mdreferences/session.mdreferences/socialite.mdreferences/starter-kits.mdreferences/templates/FortifySetup.php.mdreferences/templates/GatesAndPolicies.php.mdreferences/templates/LoginController.php.mdreferences/templates/PassportSetup.php.mdreferences/templates/PasswordResetController.php.mdreferences/templates/PostPolicy.php.mdreferences/templates/SocialiteController.php.mdreferences/templates/sanctum-setup.mdreferences/verification.md

FAQ

Что делает скилл laravel-auth?

Use when implementing user authentication, API tokens, social login, or authorization in Laravel 13.

Как установить скилл laravel-auth?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл laravel-auth запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить laravel-auth с