Installation
Laravel SDK Installation
Section titled “Laravel SDK Installation”The ByteAuth Laravel SDK provides Livewire components, webhook controllers, and session management for seamless passwordless authentication.
Requirements
Section titled “Requirements”- PHP 8.0 or higher
- Laravel 9.x, 10.x, or 11.x
- Livewire 3.x (for QR component)
- Composer
Installation
Section titled “Installation”-
Install via Composer
Terminal window composer require bytefederal/byteauth-laravel -
Publish Configuration
Terminal window php artisan vendor:publish --tag=byteauth-configThis creates
config/byteauth.phpwith default settings. -
Publish Migrations (optional)
If you want to customize the migrations:
Terminal window php artisan vendor:publish --tag=byteauth-migrations -
Run Migrations
Terminal window php artisan migrateThis creates the necessary tables for storing user public keys and sessions.
Environment Configuration
Section titled “Environment Configuration”Add the following to your .env file:
BYTEAUTH_DOMAIN_REGISTERED=yourdomain.comBYTEAUTH_API_KEY=your_api_key_hereBYTEAUTH_WEBHOOK_SECRET=your_webhook_secretEnvironment Variables
Section titled “Environment Variables”| Variable | Description | Required |
|---|---|---|
BYTEAUTH_DOMAIN_REGISTERED | Your registered domain name | Yes |
BYTEAUTH_API_KEY | API key for ByteAuth services | Yes |
BYTEAUTH_WEBHOOK_SECRET | Secret for webhook signature verification | Recommended |
BYTEAUTH_SESSION_LIFETIME | Session lifetime in minutes (default: 60) | No |
Route Setup
Section titled “Route Setup”Add the ByteAuth routes to your routes/web.php:
use ByteFederal\ByteAuthLaravel\Controllers\WebhookController;
// Webhook endpoints (called by ByteVault)Route::post('/webhook/registration', [WebhookController::class, 'handleRegistration']);Route::post('/webhook/login', [WebhookController::class, 'handleLogin']);
// Client polling endpointRoute::get('/api/check', [WebhookController::class, 'check']);
// Optional: Sample/demo pageRoute::get('/byte', [WebhookController::class, 'sample']);Disable CSRF for Webhooks
Section titled “Disable CSRF for Webhooks”In app/Http/Middleware/VerifyCsrfToken.php:
protected $except = [ 'webhook/*',];Livewire Setup
Section titled “Livewire Setup”If you haven’t already set up Livewire:
composer require livewire/livewireThe ByteAuth QR component will be automatically registered.
Verify Installation
Section titled “Verify Installation”Run the following to verify everything is configured correctly:
php artisan byteauth:checkThis command validates:
- Environment variables are set
- Database tables exist
- Routes are registered
- Webhook endpoints are accessible
Quick Test
Section titled “Quick Test”Add the QR component to any Blade view:
<!DOCTYPE html><html><head> <title>ByteAuth Test</title> @livewireStyles</head><body> <h1>Login with ByteAuth</h1> <livewire:byteauth-qr-login />
@livewireScripts</body></html>