hadyfayed/laravel-agent/laravel-auth

Claude Code and agent skill by hadyfayed/laravel-agent

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Wiring up Laravel authentication & authorization — login, register, guards, policies, gates, roles, permissions, API tokens (Sanctum), OAuth2 (Passport), social login (Socialite), 2FA; NOT for Passport/Sanctum/Socialite alone (use those references instead).

Install

npx vskill@latest install hadyfayed/laravel-agent/laravel-auth

SKILL.md

The same SKILL.md was published earlier as hadyfayed/laravel-agent/laravel-auth.

Laravel Auth Skill

Apply Laravel authentication and authorization conventions when building login/register, access control, policies, gates, roles/permissions, API tokens, OAuth2, or social login.

When to Use

  • Setting up user authentication (login, register, logout)
  • Role-based access control and permissions
  • Creating authorization policies and gates
  • API token authentication (Sanctum) for SPAs/mobile
  • Full OAuth2 server (Passport) for third-party integrations
  • Social login (Socialite) with Google, GitHub, Facebook, etc.
  • Two-factor authentication (Fortify)
  • Multi-guard authentication

Conventions Checklist

Authentication
  • [ ] Hash passwords via the hashed cast or Hash::make() — never plain
  • [ ] Rate limit login endpoints (throttle)
  • [ ] Regenerate the session after login to prevent session fixation
  • [ ] Implement proper logout (revoke tokens, invalidate session)
  • [ ] Use HTTPS in production
Guards
  • [ ] Use web (session) guard for browser, sanctum/api for tokens
  • [ ] Define guards and providers explicitly in config/auth.php
  • [ ] For Passport, set api driver to passport
Authorization — Policies
  • [ ] Use policies for model-level authorization
  • [ ] Implement before() for super-admin short-circuit (return null to fall through)
  • [ ] Use authorizeResource() for automatic controller authorization
  • [ ] Auto-discovered at App\Policies\{Model}Policy (Laravel 10+) or register manually
Authorization — Gates
  • [ ] Use gates for non-model abilities (access-admin, manage-team)
  • [ ] Define in AuthServiceProvider/AppServiceProvider::boot()
  • [ ] Check via Gate::allows() / $this->authorize() / @can
Roles & Permissions
  • [ ] Permission naming: <action>-<resource> (read-orders, approve-orders)
  • [ ] Seed roles and permissions in a RolesAndPermissionsSeeder
  • [ ] Spatie for simpler setups; Laratrust for team/multi-tenant permissions
  • [ ] Scope routes with role: / permission: middleware
API Tokens (Sanctum)
  • [ ] Add HasApiTokens trait to User
  • [ ] Grant scoped abilities (createToken('name', ['posts:read']))
  • [ ] Check abilities with $user->tokenCan('ability') or ability:/abilities: middleware
  • [ ] Revoke tokens on password change and logout
  • [ ] For SPAs: CSRF cookie → session login; set SANCTUM_STATEFUL_DOMAINS + supports_credentials
OAuth2 (Passport)
  • [ ] Use Authorization Code + PKCE for SPAs/mobile (never expose client secrets)
  • [ ] Use Client Credentials for machine-to-machine
  • [ ] Never use Password Grant for third-party apps (deprecated)
  • [ ] Define scopes via Passport::tokensCan(); enforce with scope:/scopes: middleware
  • [ ] Set token lifetimes; prune revoked tokens (passport:purge)
  • [ ] HTTPS required in production
Social Login (Socialite)
  • [ ] Validate provider names against an allowlist
  • [ ] Handle email conflicts across providers
  • [ ] Encrypt provider_token / provider_refresh_token (use encrypted cast)
  • [ ] Use ->stateless() for API/token flows
  • [ ] Exact-match redirect URIs (HTTPS in production)

Common Pitfalls

  1. Storing plain passwords — always hash
  2. Missing policy registration — register or follow auto-discovery naming
  3. Unprotected routes — guard with auth + scopes/abilities
  4. Token exposure — never log tokens; client secrets never reach the frontend
  5. No rate limiting — throttle auth endpoints
  6. Session fixation — regenerate session after login
  7. Wrong HasApiTokens — Passport vs Sanctum trait must match the guard

Package Choice

  • laravel/sanctum — API/SPA token auth (first-party)
  • laravel/passport — full OAuth2 server (third-party)
  • spatie/laravel-permission — roles & permissions (simple)
  • santigarcor/laratrust — roles & permissions (teams/multi-tenant)
  • laravel/socialite — social login
  • laravel/fortify — auth backend + 2FA

Related Commands

  • /laravel-agent:auth:setup — scaffold authentication and authorization

Related Skills

  • laravel-security — security audits and hardening

Additional references

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
13
Repository forks
1
7-day trend score
13

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/hadyfayed/laravel-agent/laravel-auth/badge)](https://verified-skill.com/skills/hadyfayed/laravel-agent/laravel-auth)

Something wrong with this skill or its page? Tell us.