Skip to content

Commit c322715

Browse files
[1.x] Add Skills support (#630)
* Add Skills support * Update SKILL.md --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent c05a2e8 commit c322715

File tree

2 files changed

+120
-24
lines changed

2 files changed

+120
-24
lines changed
Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
1-
## Laravel Fortify
1+
# Laravel Fortify
22

3-
Fortify is a headless authentication backend that provides authentication routes and controllers for Laravel applications.
4-
5-
**Before implementing any authentication features, use the `search-docs` tool to get the latest docs for that specific feature.**
6-
7-
### Configuration & Setup
8-
- Check `config/fortify.php` to see what's enabled. Use `search-docs` for detailed information on specific features.
9-
- Enable features by adding them to the `'features' => []` array: `Features::registration()`, `Features::resetPasswords()`, etc.
10-
- To see the all Fortify registered routes, use the `list-routes` tool with the `only_vendor: true` and `action: "Fortify"` parameters.
11-
- Fortify includes view routes by default (login, register). Set `'views' => false` in the configuration file to disable them if you're handling views yourself.
12-
13-
### Customization
14-
- Views can be customized in `FortifyServiceProvider`'s `boot()` method using `Fortify::loginView()`, `Fortify::registerView()`, etc.
15-
- Customize authentication logic with `Fortify::authenticateUsing()` for custom user retrieval / validation.
16-
- Actions in `app/Actions/Fortify/` handle business logic (user creation, password reset, etc.). They're fully customizable, so you can modify them to change feature behavior.
17-
18-
## Available Features
19-
- `Features::registration()` for user registration.
20-
- `Features::emailVerification()` to verify new user emails.
21-
- `Features::twoFactorAuthentication()` for 2FA with QR codes and recovery codes.
22-
- Add options: `['confirmPassword' => true, 'confirm' => true]` to require password confirmation and OTP confirmation before enabling 2FA.
23-
- `Features::updateProfileInformation()` to let users update their profile.
24-
- `Features::updatePasswords()` to let users change their passwords.
25-
- `Features::resetPasswords()` for password reset via email.
3+
- Fortify is a headless authentication backend that provides authentication routes and controllers for Laravel applications.
4+
- IMPORTANT: Always use the `search-docs` tool for detailed Laravel Fortify patterns and documentation.
5+
- IMPORTANT: Activate `developing-with-fortify` skill when working with Fortify authentication features.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
name: developing-with-fortify
3+
description: Laravel Fortify headless authentication backend development. Activate when implementing authentication features including login, registration, password reset, email verification, two-factor authentication (2FA/TOTP), profile updates, headless auth, authentication scaffolding, or auth guards in Laravel applications.
4+
---
5+
6+
# Laravel Fortify Development
7+
8+
Fortify is a headless authentication backend that provides authentication routes and controllers for Laravel applications.
9+
10+
## Documentation
11+
12+
Use `search-docs` for detailed Laravel Fortify patterns and documentation.
13+
14+
## Usage
15+
16+
- **Routes**: Use `list-routes` with `only_vendor: true` and `action: "Fortify"` to see all registered endpoints
17+
- **Actions**: Check `app/Actions/Fortify/` for customizable business logic (user creation, password validation, etc.)
18+
- **Config**: See `config/fortify.php` for all options including features, guards, rate limiters, and username field
19+
- **Contracts**: Look in `Laravel\Fortify\Contracts\` for overridable response classes (`LoginResponse`, `LogoutResponse`, etc.)
20+
- **Views**: All view callbacks are set in `FortifyServiceProvider::boot()` using `Fortify::loginView()`, `Fortify::registerView()`, etc.
21+
22+
## Available Features
23+
24+
Enable in `config/fortify.php` features array:
25+
26+
- `Features::registration()` - User registration
27+
- `Features::resetPasswords()` - Password reset via email
28+
- `Features::emailVerification()` - Requires User to implement `MustVerifyEmail`
29+
- `Features::updateProfileInformation()` - Profile updates
30+
- `Features::updatePasswords()` - Password changes
31+
- `Features::twoFactorAuthentication()` - 2FA with QR codes and recovery codes
32+
33+
> Use `search-docs` for feature configuration options and customization patterns.
34+
35+
## Setup Workflows
36+
37+
### Two-Factor Authentication Setup
38+
39+
```
40+
- [ ] Add TwoFactorAuthenticatable trait to User model
41+
- [ ] Enable feature in config/fortify.php
42+
- [ ] Run migrations for 2FA columns
43+
- [ ] Set up view callbacks in FortifyServiceProvider
44+
- [ ] Create 2FA management UI
45+
- [ ] Test QR code and recovery codes
46+
```
47+
48+
> Use `search-docs` for TOTP implementation and recovery code handling patterns.
49+
50+
### Email Verification Setup
51+
52+
```
53+
- [ ] Enable emailVerification feature in config
54+
- [ ] Implement MustVerifyEmail interface on User model
55+
- [ ] Set up verifyEmailView callback
56+
- [ ] Add verified middleware to protected routes
57+
- [ ] Test verification email flow
58+
```
59+
60+
> Use `search-docs` for MustVerifyEmail implementation patterns.
61+
62+
### Password Reset Setup
63+
64+
```
65+
- [ ] Enable resetPasswords feature in config
66+
- [ ] Set up requestPasswordResetLinkView callback
67+
- [ ] Set up resetPasswordView callback
68+
- [ ] Define password.reset named route (if views disabled)
69+
- [ ] Test reset email and link flow
70+
```
71+
72+
> Use `search-docs` for custom password reset flow patterns.
73+
74+
### SPA Authentication Setup
75+
76+
```
77+
- [ ] Set 'views' => false in config/fortify.php
78+
- [ ] Install and configure Laravel Sanctum
79+
- [ ] Use 'web' guard in fortify config
80+
- [ ] Set up CSRF token handling
81+
- [ ] Test XHR authentication flows
82+
```
83+
84+
> Use `search-docs` for integration and SPA authentication patterns.
85+
86+
## Best Practices
87+
88+
### Custom Authentication Logic
89+
90+
Override authentication behavior using `Fortify::authenticateUsing()` for custom user retrieval or `Fortify::authenticateThrough()` to customize the authentication pipeline. Override response contracts in `AppServiceProvider` for custom redirects.
91+
92+
### Registration Customization
93+
94+
Modify `app/Actions/Fortify/CreateNewUser.php` to customize user creation logic, validation rules, and additional fields.
95+
96+
### Rate Limiting
97+
98+
Configure via `fortify.limiters.login` in config. Default configuration throttles by username + IP combination.
99+
100+
## Key Endpoints
101+
102+
| Feature | Method | Endpoint |
103+
|------------------------|----------|---------------------------------------------|
104+
| Login | POST | `/login` |
105+
| Logout | POST | `/logout` |
106+
| Register | POST | `/register` |
107+
| Password Reset Request | POST | `/forgot-password` |
108+
| Password Reset | POST | `/reset-password` |
109+
| Email Verify Notice | GET | `/email/verify` |
110+
| Resend Verification | POST | `/email/verification-notification` |
111+
| Password Confirm | POST | `/user/confirm-password` |
112+
| Enable 2FA | POST | `/user/two-factor-authentication` |
113+
| Confirm 2FA | POST | `/user/confirmed-two-factor-authentication` |
114+
| 2FA Challenge | POST | `/two-factor-challenge` |
115+
| Get QR Code | GET | `/user/two-factor-qr-code` |
116+
| Recovery Codes | GET/POST | `/user/two-factor-recovery-codes` |

0 commit comments

Comments
 (0)