Skip to main content

Require login or an API key

By default Log Lens is open in a local environment. Lock it down before anyone else can reach it.

In a Laravel app - gate by your users

Add a rule in app/Providers/AppServiceProvider.php:

use LogLens\Laravel\LogLens;

// Any authenticated user:
LogLens::auth(fn ($request) => $request->user() !== null);

// A role (spatie/laravel-permission):
LogLens::auth(fn ($request) => $request->user()?->hasRole('admin') ?? false);

// A permission:
LogLens::auth(fn ($request) => $request->user()?->can('view-logs') ?? false);

Unauthorized visitors get a 403. Prefer a redirect to login? Add 'auth' to config('log-lens.middleware'). Turn it off entirely with LOG_LENS_ENABLED=false.

Standalone - require an API key

Set a token (via environment or .env):

LOG_LENS_TOKEN=a-long-random-string

Now every request must present it:

X-Log-Lens-Token: a-long-random-string

The dashboard prompts for the key once and remembers it in your browser. CLI clients and the AI skills read it from config automatically.

Always

Serve Log Lens on loopback or behind an authenticating proxy - never expose the port directly to a network. See Security.