Skip to content

Installation

The ByteAuth Laravel SDK provides Livewire components, webhook controllers, and session management for seamless passwordless authentication.

  • PHP 8.0 or higher
  • Laravel 9.x, 10.x, or 11.x
  • Livewire 3.x (for QR component)
  • Composer
  1. Install via Composer

    Terminal window
    composer require bytefederal/byteauth-laravel
  2. Publish Configuration

    Terminal window
    php artisan vendor:publish --tag=byteauth-config

    This creates config/byteauth.php with default settings.

  3. Publish Migrations (optional)

    If you want to customize the migrations:

    Terminal window
    php artisan vendor:publish --tag=byteauth-migrations
  4. Run Migrations

    Terminal window
    php artisan migrate

    This creates the necessary tables for storing user public keys and sessions.

Add the following to your .env file:

BYTEAUTH_DOMAIN_REGISTERED=yourdomain.com
BYTEAUTH_API_KEY=your_api_key_here
BYTEAUTH_WEBHOOK_SECRET=your_webhook_secret
VariableDescriptionRequired
BYTEAUTH_DOMAIN_REGISTEREDYour registered domain nameYes
BYTEAUTH_API_KEYAPI key for ByteAuth servicesYes
BYTEAUTH_WEBHOOK_SECRETSecret for webhook signature verificationRecommended
BYTEAUTH_SESSION_LIFETIMESession lifetime in minutes (default: 60)No

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 endpoint
Route::get('/api/check', [WebhookController::class, 'check']);
// Optional: Sample/demo page
Route::get('/byte', [WebhookController::class, 'sample']);

In app/Http/Middleware/VerifyCsrfToken.php:

protected $except = [
'webhook/*',
];

If you haven’t already set up Livewire:

Terminal window
composer require livewire/livewire

The ByteAuth QR component will be automatically registered.

Run the following to verify everything is configured correctly:

Terminal window
php artisan byteauth:check

This command validates:

  • Environment variables are set
  • Database tables exist
  • Routes are registered
  • Webhook endpoints are accessible

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>