Skip to content

Commit 8f33503

Browse files
cursoragentanwarx4u
andcommitted
Enhance README with MFA channels, remember devices, and custom channel docs
Co-authored-by: anwarx4u <anwarx4u@gmail.com>
1 parent 70eda74 commit 8f33503

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ Features
3030
- Publishable config and migrations; encrypted storage of TOTP secret
3131
- Extendable channel system to add providers like WhatsApp, Twilio, etc.
3232

33+
MFA Channels
34+
- Email: delivers a one-time code via Laravel Mail
35+
- SMS: delivers a one-time code via the configured SMS driver (defaults to `log`)
36+
- TOTP: time-based one-time password compatible with Google Authenticator and similar apps
37+
38+
3339
Usage
3440
```php
3541
use CodingLibs\MFA\Facades\MFA;
@@ -58,6 +64,12 @@ $cookie = $result['cookie']; // Symfony Cookie instance — attach to response
5864
$shouldSkip = MFA::shouldSkipVerification(auth()->user(), MFA::getRememberTokenFromRequest(request()));
5965
```
6066

67+
Remember Devices (Optional)
68+
- Enable or configure in `config/mfa.php` under `remember` (or via env: see below)
69+
- On successful MFA, call `MFA::rememberDevice(...)` and attach the returned cookie to the response
70+
- On subsequent requests, use `MFA::shouldSkipVerification($user, MFA::getRememberTokenFromRequest($request))`
71+
- To revoke a remembered device, call `MFA::forgetRememberedDevice($user, $token)`
72+
6173
Configuration
6274
- See `config/mfa.php` for all options. Key settings:
6375
- **code_length**: OTP digits for email/sms (default 6)
@@ -128,7 +140,11 @@ API Overview (Facade `MFA`)
128140
- **makeRememberCookie(string $token, ?int $lifetimeDays = null): Cookie**
129141
- **forgetRememberedDevice(Authenticatable $user, string $token): int**
130142

131-
Extending: Custom Channels
143+
Creating a Custom MFA Channel
144+
Steps
145+
1. Implement `CodingLibs\MFA\Contracts\MfaChannel` with a unique `getName()` and a `send(...)` method
146+
2. Register your channel during app boot (e.g., in a service provider) via `MFA::registerChannel(...)`
147+
3. Issue a challenge using the new channel name: `MFA::issueChallenge($user, 'your-channel')`
132148
```php
133149
use CodingLibs\MFA\Contracts\MfaChannel;
134150
use CodingLibs\MFA\Facades\MFA;

0 commit comments

Comments
 (0)