Skip to content

Auth ​

The Request tab with the auth eventsThe Request tab with the auth events

The auth lens records who a request, job or command was authenticated as and how: the guard that resolved the user, login attempts, logins, failed attempts, lockouts, logouts, registrations, email verifications and password resets. Each is one row in section auth, recorded as it happens; with Fortify, Sanctum or an impersonation package installed, their rows are added to the same section.

Rows ​

Every row has an event:

EventRecorded when
authenticateda guard resolved the current user
attemptinga login attempt started
logina user logged in
faileda login attempt failed
lockouta login was locked out after too many attempts
logouta user logged out
logout_current_devicea user logged out of the current device
logout_other_devicesa user logged out of their other devices
registereda user registered
verifieda user verified their email address
password_reseta user reset their password

The fields of a row:

FieldMeaningUnitMissing when
eventone of the events above-never
guardthe guard name, such as web-null on lockout, registered, verified and password_reset
userthe user as Class#id, such as App\Models\User#42-null on attempting and lockout, and on failed when no user matched the credentials
rememberwhether "remember me" was asked fortrue or falseonly present on attempting and login
credentialsthe names of the credential fields tried, such as ["email", "password"] - never their values-only present on attempting and failed
ipthe client IP of the locked out request-only present on lockout
timewhen it happenedms since the capture startednever
originthe line in your code that caused itfile and linenot recorded on authenticated rows

Totals, warnings and errors ​

Totals, each added only when its condition holds:

TotalLabelValueAdded when
auth_useruserthe user of the last authenticated or login rowsuch a row has a user
auth_failedfailed loginsthe number of failed rowsthere is at least one
auth_lockoutslockoutsthe number of lockout rowsthere is at least one

Warning: "A login was locked out after too many attempts." when the capture has at least one lockout row. It is given once, however many lockouts there are.

The auth lens reports no errors.

In the dashboard ​

For a request, the auth rows are shown on the Request tab instead of a tab of their own:

  • The request facts get a User line: the user and how they got in, such as via web guard, via Sanctum token deploy-bot or via web guard, impersonated by #1 (web guard).
  • An Authentication table lists every row except authenticated, with event, guard, user, details (the credential fields tried, remember, the IP, Sanctum abilities) and origin. failed and lockout are highlighted. Clicking a row shows all of its fields.

For a job or command, the rows get an Auth tab: one table row per event, each folding out to all of its fields. The tab has no groupings.

The totals appear on the Overview tab under Auth.

For agents ​

Who was the latest request authenticated as, and did a login fail or get locked out?

json
{ "tool": "monocle-show", "id": "latest", "sections": ["summary", "auth"] }

The failed login attempts of a capture, with the fields tried and where they came from:

json
{
  "tool": "monocle-rows",
  "section": "auth",
  "where": [{ "field": "event", "op": "=", "value": "failed" }],
  "fields": ["event", "guard", "user", "credentials", "origin"]
}

Recent captures that recorded anything about authentication:

json
{ "tool": "monocle-list", "has": ["auth"], "since": "15m" }

See For AI agents for every filter monocle-rows accepts.

Configuration ​

The lens is listed in the lenses block of config/monocle.php under its class, ExeQue\Monocle\Lenses\AuthLens. true runs it, false turns it off. It has no options of its own. See Lenses.

OptionDefaultEffect
(none)-the lens only takes true or false

Other settings that affect it:

  • Turning AuthLens off also stops the Fortify, Sanctum and impersonation rows, since they are added to its section.
  • origin decides how the origin of each row is recorded.
  • dashboard.tabs orders the tabs. The auth rows of a request are always shown on the Request tab; the Auth tab of a job or command can be placed by adding AuthLens::class to the list.
  • Masking does not apply: credential values are never recorded in the first place.
php
use ExeQue\Monocle\Lenses\AuthLens;

'lenses' => [
    AuthLens::class => true,
],

Impersonation ​

With an impersonation package installed, section auth also records an impersonation starting and ending, and marks who is really behind the user while an impersonation lasts.

PackageLens
lab404/laravel-impersonateExeQue\Monocle\Lenses\Packages\Lab404\ImpersonateLens
stechstudio/filament-impersonateExeQue\Monocle\Lenses\Packages\STS\FilamentImpersonateLens
laravel/novaExeQue\Monocle\Lenses\Packages\Laravel\NovaLens
franbarbalopez/mirrorExeQue\Monocle\Lenses\Packages\Mirror\MirrorLens

Rows it adds:

EventFields
impersonation_starteduser: the impersonated user as Class#id; impersonated_by: the impersonator as Class#id; guard is null
impersonation_endedthe same fields, when the impersonation is left

While an impersonation lasts, every authenticated row gets an impersonated_by field with the impersonator's id and guard, such as #1 (web guard). It is read from the session the package keeps, so no user is loaded from the database. The request that leaves an impersonation, where the impersonator is logged back in, is not marked.

The summary gets the total auth_impersonated_by (label "impersonated by"): the impersonated_by of the last authenticated row. The capture is tagged impersonated by #1 (web guard) in the dashboard's header and in the capture list, and the User line on the Request tab says so too. Impersonation adds no warnings or errors.

Configuration ​

Each lens is true in the lenses block by default and does nothing until its package is installed. It has no options; set it to false to stop it. It runs only while AuthLens is on.

The impersonator is read from the session keys each package uses, so these package settings affect it: laravel-impersonate.session_key and laravel-impersonate.session_guard for lab404, nova.guard for Nova (when the session holds no guard) and mirror.session.key for Mirror. filament-impersonate uses the fixed keys impersonated_by and impersonator_guard.

php
use ExeQue\Monocle\Lenses\Packages\Lab404\ImpersonateLens;
use ExeQue\Monocle\Lenses\Packages\Laravel\NovaLens;
use ExeQue\Monocle\Lenses\Packages\Mirror\MirrorLens;
use ExeQue\Monocle\Lenses\Packages\STS\FilamentImpersonateLens;

'lenses' => [
    ImpersonateLens::class => true,
    FilamentImpersonateLens::class => true,
    NovaLens::class => true,
    MirrorLens::class => false,
],

Fortify ​

With laravel/fortify, section auth also records two-factor authentication and password changes. Lens: ExeQue\Monocle\Lenses\Packages\Laravel\FortifyLens.

EventRecorded when
2fa_challengeda user was asked for a two-factor code
2fa_passeda valid two-factor code was given
2fa_faileda wrong two-factor code was given
2fa_enabledtwo-factor authentication was turned on
2fa_confirmedtwo-factor authentication was confirmed
2fa_disabledtwo-factor authentication was turned off
recovery_codes_generatednew recovery codes were generated
recovery_code_useda recovery code was used and replaced
password_updateda user changed their password through Fortify

Each row has event, user (Class#id), time and origin; guard is null. Recovery codes and two-factor secrets are never recorded.

The summary gets the total auth_2fa_failed (label "failed 2FA challenges"), the number of 2fa_failed rows, when there is at least one. Fortify adds no warnings or errors.

Configuration ​

FortifyLens is true in the lenses block by default, has no options, and does nothing until laravel/fortify is installed. It runs only while AuthLens is on.

php
use ExeQue\Monocle\Lenses\Packages\Laravel\FortifyLens;

'lenses' => [
    FortifyLens::class => true,
],

Sanctum ​

With laravel/sanctum, section auth also records the personal access token a request authenticated with, as a row with event token. Lens: ExeQue\Monocle\Lenses\Packages\Laravel\SanctumLens.

FieldMeaningMissing when
eventtokennever
guardsanctumnever
useralways null; see owneralways
token_idthe token's idnever
token_namethe name the token was created withthe token has no name
abilitiesthe token's abilities, such as ["orders:read"]the token has none
ownerthe token's owner as Class#idthe token has no owner
time, originas on other auth rowsnever

On the Request tab, the User line shows the owner via Sanctum token <name>, and the Authentication table lists the abilities. Sanctum adds no totals, warnings or errors.

Configuration ​

SanctumLens is true in the lenses block by default, has no options, and does nothing until laravel/sanctum is installed. It runs only while AuthLens is on. The token value is never recorded; the Authorization header it came in is masked on the Request tab by the default masking settings.

php
use ExeQue\Monocle\Lenses\Packages\Laravel\SanctumLens;

'lenses' => [
    SanctumLens::class => true,
],

Requirements and limits ​

  • The auth lens needs nothing beyond Laravel. Fortify, Sanctum and the impersonation lenses need their package and run only while AuthLens is on.
  • Only Laravel's auth events (and the events of the packages above) are recorded. A guard that never fires Authenticated, or a login done without Laravel's events, does not show up.
  • Credential values, passwords, recovery codes and token values are never recorded.
  • Sanctum token rows need a laravel/sanctum version that fires TokenAuthenticated. Requests authenticated with Sanctum's session cookie (SPA authentication) get no token row.
  • impersonated_by is only added where there is a session to read it from, so requests on a stateless guard are not marked.