hadyfayed/laravel-agent/laravel-auth
Claude Code and agent skill by hadyfayed/laravel-agent
- community
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-authSKILL.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
hashedcast orHash::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/apifor tokens - [ ] Define guards and providers explicitly in
config/auth.php - [ ] For Passport, set
apidriver topassport
Authorization — Policies
- [ ] Use policies for model-level authorization
- [ ] Implement
before()for super-admin short-circuit (returnnullto 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
HasApiTokenstrait to User - [ ] Grant scoped abilities (
createToken('name', ['posts:read'])) - [ ] Check abilities with
$user->tokenCan('ability')orability:/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 withscope:/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(useencryptedcast) - [ ] Use
->stateless()for API/token flows - [ ] Exact-match redirect URIs (HTTPS in production)
Common Pitfalls
- Storing plain passwords — always hash
- Missing policy registration — register or follow auto-discovery naming
- Unprotected routes — guard with
auth+ scopes/abilities - Token exposure — never log tokens; client secrets never reach the frontend
- No rate limiting — throttle auth endpoints
- Session fixation — regenerate session after login
- 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
- Core auth: guards, policies, gates, roles/permissions, 2FA → references/core-auth.md
- API/SPA token authentication (Sanctum) → references/sanctum.md
- Full OAuth2 server (Passport) → references/passport.md
- Social login (Socialite) → references/socialite.md
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
- SKILL.md in the repositoryCheckingskills/laravel-auth/SKILL.md
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
[](https://verified-skill.com/skills/hadyfayed/laravel-agent/laravel-auth)