Differences From PHP
On this page
- Introduction
- Not Available Yet
- What Behaves Differently
- Signing In and Out
- Remember Me
- Ending Another Session
- Policies and the Pipeline
- Requiring a Second Factor
- Managing Authenticators
- Factors of Your Own
- Code Factors
- Passkeys and Attestation
- Devices
- Sessions and the Registry
- Impersonation
- Single Sign-On
- Signing In From Your Own Routes
- Pages and Responses
- Routes
- Risk
- Events
- The Security Log
- Emails
- Passwords
- Email Changes and Reserved Addresses
- Protected Attributes and Users
- Console Commands
- Services for Your Own Code
- Test Helpers
- What laravel-rust Would Need
Introduction
The crate covers nearly all of the PHP package and passes the whole contract suite. This page lists everything that isn't the same: what isn't there yet, what works differently because Rust or laravel-rust works differently, and the laravel-rust API that would let the crate match the PHP package exactly. Each Rust page links here from the sections it affects.
Not Available Yet
These need something laravel-rust doesn't have (see What laravel-rust Would Need):
- Laravel's own events.
Failed,Lockout,PasswordReset,RegisteredandVerifiedaren't dispatched. Keyring's own events are the only ones. sessions.overlapping_requests. Keyring's ownStartSession, which keeps a request that overlapped a sign in, step-up or sign-out from saving the old session again, isn't there. The crate behaves as the PHP package does with it off.- Translations. laravel-rust has no translator or locale, so every message is the PHP package's English one. There's no
lang/. - Rehashing a password on sign in. The PHP
Passwordfactor'srehash()isn't ported: laravel-rust's guard keeps a fingerprint of the password hash in every session, so a new hash would sign out every other session of the user.
This one needs something webauthn-rs-core doesn't have:
- Ed25519 passkeys.
EdDSAinwebauthn.algorithmsis never offered, and an Ed25519 key added on the PHP side is refused like a wrong answer. See Passkeys and Attestation.
These have nothing in the way, and aren't done yet:
- A pipeline step that locks the attempt out (
$context->lockout()). A step can fail a verification, but not lock it out. - Dangerously replacing or removing
EnsureNotThrottled,VerifyFactororCompleteAttempt. They're fixed places in the crate's code rather than steps. - A second passkey factor that signs in alone (
WebAuthn::passkeys()->as(...)).webauthn.keysfactors only ever come second. - Reserved lookalikes in scripts beyond Latin, Greek and Cyrillic. See Email Changes and Reserved Addresses.
And these have no counterpart, because there are no Eloquent models:
- Swapping the models (
useAuthenticatorModel()and the rest). The tables are Keyring's own. - The
HasKeyringtrait. Your application calls Keyring where the trait's model events would fire:protection::guard()where it saves users,address_reserved()where it sets an address, anduser_deleted()oruser_soft_deleted()where it deletes users.UserKeyring::of(&user)stands in for$user->keyring.
What Behaves Differently
Signing In and Out
- Signing out uses
Auth::logout, which gives the user a new remember token and so signs out their other remembered browsers too. laravel-rust has no way to sign out one browser alone, as Laravel'slogoutCurrentDevice()does. That covers every sign-out: Keyring's own, a session that runs out, one used up by a "remember me" cookie used twice, and one with no cookie of Keyring's. - Impersonation is the exception. It signs the browser out itself, emptying the session and taking back the
remember_webcookie, becauseAuth::logoutwould change the impersonated user's token for something the impersonator did. Only impersonation does this: it relies onremember_web, a cookie name laravel-rust keeps private, and it leaves the request'sAuthholding the user until the request ends, which is only safe where Keyring answers straight away. - A new password signs out every other session. laravel-rust's guard keeps a fingerprint of the password hash in each session and signs out every session made before it changed, so
sign_out_others: falsecan't keep the others. Their records end at once anyway, aspassword_changed, with aSessionEndedfor each, and each browser gets thesigned-out401on its next request.sign_out_othersonly decides the rest of signing out everywhere, such as a new remember token. The browser that changed the password carries on, signed in again under the new fingerprint as it moves to its new ID. - A signed-in browser at a guest page is redirected to
home. The PHP package'sguestmiddleware sends it where Laravel'sRedirectIfAuthenticateddoes:/unless the application callsredirectUsersTo(). - The session lock. A request that waits the full 10 seconds for the session lock gets a
500, not a423. With thecookiesession driver, two requests sent with one cookie take turns, but each carries its own copy of the session, so the record each moves to is what stops a copy carrying on. - Pending logins and the address. A pending login ends when the user's address changes, reading it through your
ChangesEmailsaction, or for a user type that derivesMustVerifyEmailitsemail_for_verification(), since laravel-rust'sAuthenticatabledoesn't give one. A user type with neither has no address Keyring can read, and only a new password ends its pending logins. - A passkey alone that fails names its account, and only the address's limit bounds it, so its
factor_failedentry is a refusal on the account, writtensecurity_log.refusalstimes an hour at most, where the PHP package writes every one. - When
FactorFailedfires. After the failure is counted, so a listener that fails can't keep it from counting. The PHP package dispatches it before.CloneSuspectedand the quiet refusal'sLockoutlikewise, still in the PHP package's order. - Your own sign out. Your
auth.logout()is noticed byAuthenticateSessiononce the handler returns, so only on routes in thewebgroup. The record ended is the one the session was on when it signed out, so a handler that moved the session to a new record first (a step-up,Sessions::sign_out_others()) ends the new one. One that signs someone else in after signing out isn't seen, and an impersonation the handler started before signing out leaves the impersonator's parked session to time out. The reason is alwayslogged_out. There's noSessions::because(). - Locking the user. The PHP package runs every change to a user's sessions, password and sign-in methods under a row lock on the user's model. Here it's one cache lock keyed on the user for all three, so it needs a cache store with locks that every server shares. The cache lock doesn't keep the PHP side out, so changing the user's sign-in methods, and on the
databasesession driver moving a session to a new record and a sign in whensessions.maxis set, also take the PHP package's row lock,SELECT ... FOR UPDATEon the user'sidin the tablesession_user_typenames, on the default connection. It's waited for 5 seconds at most, and past that the change fails. Ending sessions doesn't need it: it looks again until none is left open. SQLite has no row locks, and a table that isn't there is skipped, with a warning logged once, and looked for again next time. - User IDs. Users need integer IDs (the
IntegerIdbound): the tables'authenticatable_idcolumns are big integers, as the PHP package'smorphs()makes them by default. Each application has one user type.
Remember Me
- A session your application signs in itself with
Auth::login(..).remember(true)is recorded, but not as remembered, since laravel-rust doesn't say its remember cookie was set (the PHP package'srecallerQueued()). It gets noremembered_sessioncookie, so its remember cookie is signed out as one without Keyring's cookie is. - Every sign-out uses
Auth::logout(see above), so any sign-out also stops "remember me" in the user's other browsers, where the PHP package signs only that browser out.
Ending Another Session
laravel-rust has no way to destroy another browser's session by its ID, so ending one ends its Keyring record, and AuthenticateSession signs that browser out on its next request. Its session data stays in the store until it expires. A request that browser already has in flight when the record ends still finishes.
Policies and the Pipeline
- The policy closure goes to the provider's
policy(), notKeyring::require().devices.trusted_policy, which stood in for one, is gone: a closure reads trust fromattempt.device(). - Steps are values given to the provider's
pipeline(), not class names the container builds, named byStep::name()(their type's own name without its path by default, as the PHP package names a step by its class) and the constants inpipeline. - Steps of your own only run between
VerifyFactorandCompleteAttempt. The rate limits and the proof before them, and the sign in after, are fixed places in Keyring's code, so placing a step before or after them stops the application booting, as replacing or removing a mandatory step does. dangerously_replace()anddangerously_remove()only takeEnsureNotRiskLockedandDetermineRequirement(and the steps that aren't mandatory).EnsureNotThrottled,VerifyFactorandCompleteAttemptcan't be changed, even dangerously. Steps are named by their short names (EnsureNotRiskLocked) indangerously_changed_steps(), the warning (totracing, once at boot) andVerificationRefused::skipped. The log entry'sskippedis the PHP package's.- The final check only looks at the risk lock, as the throttle and the proof always run before the steps here, and only for a verification that completes the attempt, as in PHP.
- With
DetermineRequirementdangerously removed, or a replacement that sets no requirement, a sign in is asked what the policy asks, where the PHP package's never completes.KeyringConformancefails until each dangerously changed step is acknowledged withacknowledge_dangerous_steps(). - A step can only fail a verification (
Flow::Fail, as$context->fail()), not lock it out. - The context carries the request, the factor's key, whether it identified the user, the attempt as the policy sees it and the requirement once
DetermineRequirementhas run, not the PHP package'sFactor,AuthenticatororVerificationobjects. - A factor checked inside another request (the password that adds a first second factor or removes the last, the key that proves a change to a frozen account) doesn't run the steps, as the PHP package's
FactorCheckdoesn't. RequireAssurance's confirm asks for the whole level afresh, where the PHP package'sunlessReached()builds on what still counts toward it. Its levels and modifiers are methods (RequireAssurance::aal2().device_bound()) rather than a parameter string, as laravel-rust has no middleware names.RequireAssurance::aal1()takes no recovery code alone, where the PHP package'skeyring:aal1does. This is a deliberate tightening: a recovery code stands in for a lost factor beside another one, never as the whole of what's asked.
Requiring a Second Factor
RequireEnrollmentandRequirePasswordChangeknow Keyring's own routes by the handler of the route the request matched (its path underlaravel_keyring::http, fromstd::any::type_name), where the PHP package names them (keyring.*,logout,verification.*,user-password.update): laravel-rust's routes have no names. Should that path ever read differently, nothing of Keyring's is let through, rather than more.enrollment_exceptandpassword_change_excepttake paths, a*matching anything, where the PHP package's take route names.- The requirement a page is saved with for
continueis the middleware's own. ARequireAssuranceon the same route isn't gathered into it, as the PHP package'stoCarryOn()gatherskeyring:aal2, since laravel-rust doesn't let a middleware see the route's other middleware. A user who enrolls enough forRequireEnrollmentbut not for the route'sRequireAssuranceis handed the page, andRequireAssurancesends them to enroll again, with the page saved for its own requirement. - The page saved is the request's URL as it came, where Laravel's
fullUrl()sorts the query. Keyring's own pages, which are never saved, are known by their paths. - A hold placed from code without a session reaches a session that found none within the last minute when that minute is up, as in the PHP package. The page a held user was headed for is kept only for a page the browser navigated to, as the PHP package's
Detourskeeps it.
Managing Authenticators
- The routes are there once
features.manage_authenticatorsturns them on, off by default as in the PHP package's config. A browser that doesn't ask for JSON goes back with the status, and anything that came with it forhttp::result(). - laravel-rust's router takes one parameter name at a place in a path, so all five authenticator routes use
{factor}, also where they name an authenticator. The URLs are the PHP package's. - An authenticator app is set up with six digits and
factors.totp's digest and issuer (SHA-1 andapp.nameby default), and the user's mail address as the account name (a passkey'suser.nametoo), or the user's ID for one with no address, since laravel-rust's user doesn't say its username. The QR code is theqrcodecrate's SVG, 192 pixels across with no margin, not BaconQrCode's markup. - Who may enroll is given to the provider (
allow_enrollment_when()). Without it, a user type that derivesMustVerifyEmailwaits for a verified address, and with registration on, whether addresses are verified at all is whether the provider was givenverify_emails()withfeatures.email_verificationon, where the PHP package asks whether the model implementsMustVerifyEmail. Enrolling then fails with a server error naming what to change. - The password checked for adding or removing a factor, and a proof, dispatch
AttemptingandFactorVerifiedas a challenge's answer does, besides the PHP package'sFactorFailed,LockoutandAccountLocked.
Factors of Your Own
- A primary or second factor of your own says what it proves (its categories, phishing resistance and device binding) once, for the factor, where a PHP factor's
categories(),phishingResistant()anddeviceBound()can vary with the authenticator. What a session proved with one counts for the categories recorded then, as in the PHP package. - There's no
attested(),present(),limits()orauthenticators()(virtual authenticators) to override. It counts under the configured limits: the address's alone for a primary factor, or the typed name's and the account's whenidentified_byincludes the username field. IdentifiesUsers::verifyandChecksProofs::verifyanswer whether the proof holds rather than with aVerification.- Keyring doesn't validate their fields (
identificationRules(),rules(),enrollmentRules()): the factor does, answeringInvalidInput. A primary factor's sign in validates inIdentifiesUsers::validate(), which Keyring calls before the limits, so a missing field is answered alike whether or not the account is refused without saying so. - A primary factor gives the challenge page no props of its own (
challengeis[]). AnIdentified::by(user, id)naming a row that isn't the user's confirmed authenticator of that factor is taken as nobody found, afterstall(). Enrolls::confirmgets whatbeginkept without the keys startingkeyring., which are Keyring's.- A factor's key, and
webauthn.keys' keys, name it across the whole process, as code factors' do. - With no
factorsset, the crate has the password, authenticator apps, recovery codes and passkeys, where the PHP package'sKeyring::factors()with nothing listed has the password alone.
Code Factors
- A factor is named by its key alone wherever it's kept (a pending login, the session's verifications), so how a code factor is classified (the categories it proves, one per user or many) is known by its key across the process: two applications in one process can't classify one key differently, which stops the second booting.
- A code factor whose key or settings are refused is never registered, and stops the application booting. Beyond the PHP package's bounds (six digits, ten minutes), a code of more than 18 digits, or a factor allowing no wrong guesses, also stops it booting.
- Beginning an enrollment (
POST /user/authenticators/{factor}) is under thekeyringlimiter (limits.forms), where the PHP package leaves it out. - A code factor says what it proves once, for every one of its authenticators, with
categories(), where a PHPCodeFactorsubclass'scategories()is given the authenticator. One that proves nothing stops the application booting. - Its own
limits(), aFactorLimits, replace those of the four ofper_ip,per_account,consecutiveandconsecutive_elsewhereit gives, where a PHPlimits()returns any limits at all. - Its sender's
new_authenticator()returns the name, secret andmetato save, rather than an unsaved model. - Codes are kept in the default cache store, the one the rate limits use, as there's no
cache.limiterto pick another. - The emailed code goes in Keyring's own plain-text and HTML email with the PHP package's wording, sent at once.
notifications.verification_code()oremail_codes.mail_usingreplaces it, the first before the second. A user with no address (mail_address()isNone) is sent nothing.
Passkeys and Attestation
- Key algorithms.
webauthn.algorithmsis ES256 alone by default, where the PHP package's is ES256 and EdDSA. webauthn-rs-core 0.6.2, which checks the signatures, reads an Ed25519 key but can't verify with it, and checking one withed25519-dalekdirectly would mean redoing the whole assertion and registration checks outside webauthn-rs-core, which isn't a small or safe addition. SoEdDSAin the list is never offered, an Ed25519 key is never added, and one added on the PHP side is refused like a wrong answer. RS256 is offered, added and signs in when the list names it, as in the PHP package. - Attestation roots.
webauthn.attestation_rootsare trusted for every model, as the PHP package's ownConfiguredRootsdoes, unlesswebauthn.trustsgives each model's roots. That's a value in the config rather than a class the container builds, and a root it gives that's neither PEM nor base64 DER is reported and refuses the key. - The chain. webauthn-rs-core checks the chain against the roots, as of now on the application's clock, and Keyring refuses what the PHP package's hardened validator does besides: a signature in the chain over anything but SHA-2 (RSA PKCS #1 v1.5 or ECDSA), Ed25519 or Ed448, and an RSA key under 2048 bits that signed one of its certificates. The key's own attestation certificate isn't sized, and one listed as a root itself is taken without a chain to check, as in the PHP package.
- Finding the root. The root is found by a name exactly equal to the last certificate's issuer, so a root whose name only matches loosely never signs for a chain here. Any root by that exact name with a short key refuses the key, where the PHP package takes the chain when another root by the same name signed it.
- The attestation type kept is always
basic. - U2F statements. A
fido-u2fstatement signs neither the flags nor the AAGUID beside it, so one with a flag set or an AAGUID that isn't all zeros is refused. The PHP package refuses the flags, and takes the AAGUID, which lets a U2F key pass for a modelaaguidslists.
Devices
- The describer is a closure in
devices.describe_using(), where a panic stands in for the PHP package's exception. - The locator is an
Arcindevices.locator, not a class the container builds, and two lookups that start at once within one request may both call it. - The PHP package's
Location::of()isn't public: a signal reads the location withAssessment::location(). - The device a sign in comes from is kept in the pending login by its ID, and loaded again each time the policy is asked, the owner's alone and only while it isn't signed out, so trust taken away meanwhile counts at once.
Sessions and the Registry
- The session limit. When ending a session past
sessions.maxfails, the sign in fails. On thedatabasedriver on the default connection, where the sign in holds the user's row, it all rolls back, the new record and the sessions it ended, as the PHP package's database registry does when it shares the user's connection. Where it doesn't (another driver, asessions.connectionof its own, SQLite, or a user table that isn't there), its new record is deleted, and the sessions ended before the failure stay ended and announced. - Registry drivers. Keyring's migrations always create
keyring_sessionson the default connection, so asessions.tableorconnectionof your own is yours to create. The cache driver keeps the PHP package's keys and fields, but laravel-rust's cache stores JSON where Laravel stores PHP-serialized arrays, so a PHP and a Rust application can't share a cache registry (the database driver's rows are still shared). "Everyone signed out" on it lasts ten years, not forever, and its lock on an owner is held per task. A driver of your own is an instance given tosessions.extend(), not a closure for the manager, and is given the reason and the time with each call. It never announces, so there's noAnnouncingSessionRegistryto wrap. The sweep, and the guard that ends an impersonation parked on a record that ends, are the database driver's alone. - Announcing. A session that ends is announced straight away, or, when it ended while the user's sessions were locked, once the lock is let go, so no listener runs under it. Nothing in the crate revokes inside your database transaction, so there's no waiting for one to commit, as the PHP package's
whenDurable()does. Ending several sessions at once ends them one statement each, each only if it's still open, so what's announced is exactly what that call ended, and finds them again until none are left. The PHP package ends them in one statement under a row lock. What was ended before a statement fails is announced, then the failure is returned, except in a sign in that rolled back whole (see the session limit above), where nothing stayed ended. What the sweep and the announcements read is read from the database that was written to. - Pages that also serve guests.
sessions.continue_as_guestlists paths, a trailing*matching the rest, where the PHP package's names routes. The URL a page visit is sent back to keeps its query string as the browser sent it, where Laravel'sfullUrl()sorts its parameters.
Impersonation
- Who may impersonate whom is given to the provider (
allow_impersonation_when()), not a globalKeyring::allowImpersonationWhen(). The closure has the PHP one's shape, the impersonator and then the user. impersonation::impersonate()andstop_impersonating()take the request'sAuth,SessionandRequest.impersonate()asks whatimpersonation.requires_aal2andfresh_forask before it starts anything, and returnsImpersonationStart::StepUpwith the step-up's answer for you to send, where the PHP package leaves that to the route's middleware.- Starting asks
impersonation.requires_aal2andimpersonation.fresh_forrather than a list of middleware, as laravel-rust has no middleware names for a setting to list. The confirm for AAL2 asks for both factors afresh, where the PHP package's builds on what still counts toward it. - laravel-rust has no
->block()for a route, so you list your start route insessions.block. - Every start, Keyring's route's too, also refuses, as
impersonating, a start from a session record an impersonation that hasn't ended already parked: a copy of the session from before a start. The PHP package doesn't check this. That impersonation ends as it's refused, so a session left that way isn't refused again. ImpersonationRefusal::Myselfis the PHP package'sSelf, a name Rust keeps for itself. Its value isself.- Someone's name, for the banner and the sessions list, is their
mail_address()'s display name, or the address itself without one, standing in for the PHP package'snameattribute, then the username. - A user's password changing while they're impersonated sends the admin back, but laravel-rust's guard takes back the browser's
remember_webcookie as it lets the user go, which Keyring can't stop: the admin keepsremembered_session, and loses the cookie that would sign them in once their session runs out. - The claim that only one request ends an impersonation is kept in the default cache store, where the PHP package keeps it in
cache.limiter's. - The migration always runs, so there's no
MissingMigration. A start whose session can't be saved has its record ended (EndUnsavedSignIns) rather than left for the sweep. - There's one user type, so an account outside Keyring's guard is never asked about.
Single Sign-On
- Providers are
SsoProvidervalues insso.providers. A driver of your own implementssso::IdentityProviderand is registered withsso.extend(), given the provider'sSsoProvider(anything else it reads inoptions) rather than an array and a name. Its callback is the query string as a map rather than the request, and a failure is anSsoFailedinside the error. sso::provider()andproviders()give aConfiguredProvider(its name, label, freshness and whether it can reauthenticate) rather than the driver itself.sso::start()andsso::complete()take the session, and a provider that isn't configured is a404from them, where the PHP package throwsUnknownSsoProvider.sso::start()refuses Keyring's own purposes (login,link,confirm), which the PHP package'sstart()takes.- The identity your driver returns is given the provider's name and the request whatever it says, and refused without an issuer or subject, where the PHP package takes it as it comes.
sso::link_new_account()has no PHP counterpart: the PHP example creates the row itself.freshnessis anSsoFreshness, so the PHP package'sfalseforneverhas no spelling here.- RSA public exponents are limited to what the
rsacrate takes (33 bits, where web-auth/cose-lib takes up to 256). Every provider uses 65537. - Host names are resolved through the system's resolver, and a name that's then resolved again by the HTTP client can still answer differently, as in the PHP package.
- A discovery document or key set the PHP side cached in a store both share is read as missing and fetched again, as the two serialize differently.
- Building a driver on Keyring's. The bases are kept, not extended: an OAuth 2.0 driver keeps an
OAuth2and implementsIdentityProvider, passing its endpoints toauthorization_url()andtokens(), and an OpenID Connect driver keeps anOidcand implementsOpenIdConnect. Default scopes, label and freshness are builder methods.OpenIdConnect's hooks are given the discovered issuer or the discovery document rather than reading them from the object, and Microsoft's keys are filtered one at a time withtrusts_key()rather than by overridingsignedByOneOf(). A driver built onGoogle, or another of Keyring's, passes each of that driver's hooks on itself.checkCallback(),authorizationParameters(),exchange(),tokens(),mayFetch()andendpointIn()have no hook.SignedTokenisn't public, so a driver checks an ID token withoidc::verify().oidc::userinfo()has no PHP counterpart, and a userinfo answer that's a JWT isn't read. Keyring::linkRootUsing()is the provider'slink_root_using(), andFakeIdentityProvideris inlaravel_keyring::testing(see Test Helpers).
Signing In From Your Own Routes
sign_in::attempt()takes aSignInWithrather than a factor's key, and for single sign-on the identity and "remember me" in it, where the PHP package reads them from the request, which laravel-rust's can't have added to. Withfeatures.ssooff,Ssois a404.- A browser someone is signed in on is sent
homebyattempt(), as by Keyring's own routes, where the PHP package signs the new user in over them. as_user()refuses while the browser is impersonating someone, with anImpersonatingerror, a403, where the PHP package's ends the impersonation first. It takesVerified::password()orVerified::authenticator(id), one of the user's own sign-in methods, whereSignIn::as()takes anyVerification.- There's no
keyring-login-optionslimiter to put on your own callback, since laravel-rust has no named limiters for a route. Put a rate limit of your own on it. - After a confirm, the page a step-up goes back to is checked against the request's origin and
APP_URL's. The PHP package'skeyring.domainhas no counterpart.
Pages and Responses
- Keyring renders through Inertia only with the crate's
inertiafeature, and only for a request that ran laravel-rust's Inertia middleware, where the PHP package uses Inertia whenever it's installed. An Inertia component that doesn't exist isn't checked for. - A page given with
render_using()gets the request beside the props, and answers with aResponse. KeyringResponsecovers the PHP package's response contracts butFailedResponseandLockoutResponse: a refusal is laravel-rust'sInvalidInputerror, which you render your own way withErrors::render.- A browser's refusal on fields is given a
422so laravel-rust redirects it back. The redirect doesn't show it. - laravel-rust asks an application whose user type derives
MustVerifyEmailto mark its verification page, which a provider can't do, so you calllaravel_keyring::http::verification_page::<User>(auth)inwith_auth.
Routes
http::routes()registers underKeyringConfig::prefixanddomainitself, as Keyring builds every URL to its routes from those two settings rather than from route names. Set them in the config rather than wrapping the routes in a group of your own. Wrapped in a group with a prefix anyway, the session lock and the emailed links'no-referrerstill hold, but Keyring's URLs don't follow the group's prefix.- There's no
middlewaresetting: withroutesoff you wraphttp::routes()in middleware of your own. - A
domainhas to be a plain host, and aprefixa plain path: a{placeholder}, a query, a fragment or whitespace stops the application booting. sessions.continue_as_guestlists Keyring's own pages with their prefix.- With
sessions.middlewareoff, Keyring's own routes are a500namingAuthenticateSessionuntil you add it. - WebAuthn origins don't follow
domain, as in the PHP package. ValidateSignaturenames a refused link by the name it's given, as laravel-rust's routes have no names. There's nokeyring.throttle:{name}for a limiter of your own.
Risk
- Signals are values in
risk.signals(Arc<dyn Signal>), not class names the container builds, and an option is a field (InactiveAccount { after: Duration::from_secs(180 * 86_400), ..Default::default() }) rather than a string duration. A reason names a duration in the largest unit it's a whole number of (15m,1h,90d), where the PHP package writes the config's text as given. risk.respondis a plainfn(&Risk, Checkpoint) -> Action, which can't capture anything.Assessmentcarries the user asuser::<U>(), their ID and type, the attempt as the events see it, the browser's device ID, and on a request the session asevents::RegisteredSession, rather than the models themselves.risk::assess()andrisk::enforce()are public, for a pipeline step that replacesAssessRisk.enforce::<P>()takes the user provider's type, and has no session to note a password hold in.Assessment::of_step()builds the assessment from a step's context, andAssessment::for_user()outside a sign in.- Locks are in the default cache store. There's no
risk.store. - A
Finding's and aRisk'sscoreis au32, where PHP's is anintthat could be negative. BreachedPasswordasks Have I Been Pwned's range API through laravel-rust's HTTP client, as Laravel'sNotPwnedVerifierdoes. There's noUncompromisedVerifierto swap.- A request-time step-up notes the record it moved to in the default cache store, where the PHP package uses
cache.limiter.
Events
- An event carries what Keyring read from the request rather than the request itself:
FactorFailedhas theusernametyped,LockoutandAttemptingthe factor, andProtectionBypassedtheuserwho made the change. - Events whose PHP payload is a model carry plain values (an
Authenticatorwith its ID, factor and name; anAttemptwith its purpose and verifications).FactorFailed,RecoveryCodeUsedandCloneSuspectedcarry theuserthe PHP package gets withauthenticator->user(). NewDeviceSignedIn::revoke_url()takes the days as anOption<u32>and returns aResult, as the link can't be signed without anAPP_KEY.DeviceRevokedcarries the device's ID and name, not its model.VerificationRefusedcarries theuserbeside the attempt, and the skipped steps' short names.ProviderIdentityAcceptedcarries theIdentitywith its request's secrets.Identity::without_secrets()is the PHP package'swithoutSecrets(), for a listener that keeps it.
The Security Log
- An entry the table won't take, or every entry with
security_log.enabledoff, is atracingevent under thekeyring::security_logtarget, with the PHP package's message (Keyring: {type}) and context, rather than a line on a log channel. There's nosecurity_log.channel. - tracing has no
noticeorcritical, sonoticegoes out atINFOandcriticalatERROR, with the severity as a field. - An unlisted type with a character outside ASCII is passed over, as
Collation::fold()'s transliteration isn't fully ported and it could be a spelling of one of Keyring's.
Emails
- Security emails. Your user implements laravel-rust's
ReceivesMail, which says where they go. laravel-rust builds an email as it queues it, where Laravel builds it in the worker, so one that can't be built (an address the mailer won't take) is reported and the request carries on. Each is Keyring's own plain-text and HTML email rather than Laravel's mail template. - Replacing one. One kind's email is replaced with a closure given the notice (
notifications.mail(kind, ...)) rather than a notification class built through the container, so it's always an email, on the mail channel.mail_usingreplaces every other kind's at once. - Emails a flow needs (
verification_code,confirm_email_change,email_change_notice,email_address_in_useandalready_registered) aren't kinds: each has a method of its own onnotifications, given a value with what the email says, as do the reset and verification links. A replacement is always an email on the mail channel. There's nocreateUrlUsing(): the closure gets Keyring's link, and the reset token for a page of your own. None can be turned off: a PHP app that sets one tonullgets aMissingNotificationrefusal, and a Rust app turns the flow off instead. Only the reset and verification links carry the user. whenis in UTC. The account-locked email has its reset button while password resets are on, and is sent in the background, off the refused sign in's answer, so asyncqueue can't make a locked account's answer slower than a name nobody has.- Each kind's count goes by
authenticatable_typeand the user's ID, where the PHP package goes by the class name. - The account emails (the reset link, the verification link and
AlreadyRegistered) are Keyring's own plain-text and HTML emails, with the wording of Laravel'sResetPasswordandVerifyEmailand the PHP package'sAlreadyRegistered. There's noRegisteredorVerifiedevent to send them through. The reset tokens' table is alwayspassword_reset_tokens, the table of a new Laravel app, which your migrations create.
Passwords
- Password rules.
PasswordRulesis a builder your actions call (PasswordRules::new().context([..])at registration,PasswordRules::for_user(&user)for a change or a reset, thencheck()orvalidate()), not a list of Laravel rules..min()and.max()stand in for the closure that adjusts the PHP package'sPasswordrule, and your own rules go beside it in the action.min()only ever raises the minimum, never under eight. - A password that isn't a string is refused as
must be a string(with the confirmation, when that differs) and nothing more, where Laravel's validator also measures its length. - The user's words are their
mail_address()'s display name and address, standing in for thename, username and email attributes. - The common passwords are a copy of the PHP package's list in the crate's own
resources/passwords/common.txt, which a test holds to the PHP package's file. - A password bcrypt can't take is refused on a change or a reset before the action runs, as it is at registration, with every rule of
PasswordRulesit breaks. - The features start off. Registration, password resets, changing the password and email verification are off until you turn them on in
featuresand give the provider your actions, where the PHP package's config turns them on. One that's on without its action, email verification withoutverify_emails(), or registration that hides who has an account without email verification, stops the application booting, where the PHP package fails the request. The actions are traits (CreatesNewUsers,ResetsUserPasswords,UpdatesUserPasswords) given the form as JSON, its passwords in NFC. - Taken addresses. Registration counts an address as taken when your
CreatesNewUsers::taken()says so, or by default when the provider'sfind_for_login()finds an account with it, when it's reserved for its previous owner during an email change, and when the insert breaks a unique index. The PHP package looks the address up without global scopes, so a soft-deleted account counts: answer that intaken().
Email Changes and Reserved Addresses
- Your
ChangesEmailsaction reads and saves the address, where the PHP package reads and force-fills the model'semailattribute.update()is told whether the address is newly verified. - Each step runs under the cache lock on the user, with a confirmation's and an undo's writes in one database transaction that starts by locking the change's row. The action's own write joins that transaction only through the default connection from the same task: one written elsewhere can land while the claim beside it rolls back, so a confirmation that finds the account already has the new address finishes the change (applied, the old address reserved and its undo working), where the PHP package would cancel it.
- An undo announces what it removed (
AuthenticatorRemoved) once its transaction has committed and everyone is signed out, so a listener that fails can't take the undo back, as it would in PHP. Its error answers the request once the rest is done. - An undo loads the account with the provider's
find(), so one the provider doesn't load, such as a deactivated account, gets no address back and the link is refused, where the PHP package finds it without global scopes. - The default
ChangesEmails::taken()asksfind_for_login(), which looks users up by what they sign in with: an application whose users sign in with a username answers it itself. - The link's expiry in the confirmation email is said as Carbon's
diffForHumans()would, in English. - Reserved lookalikes. The PHP package folds an address with Laravel's
Str::transliterate(). It's ported as a table of what that does to Latin (Latin-1 to Extended-E, IPA and the phonetic extensions), Greek and Cyrillic (with Extended-B and -C) letters, general punctuation, and every format character. A character from another script (Chinese, Japanese kana and kanji, Korean and the rest) is kept, lowercased, where the PHP package transliterates or drops it, so an address with one is only found under its own spelling, and its hash doesn't match the PHP side's: a reservation either side makes for such an address isn't found by the other. If your users have such addresses and both sides take registrations, check reservations on one side only.tools/fold-table/generate.phpwrites the table from the PHP package.
Protected Attributes and Users
- laravel-rust has no model events, so nothing checks every save of a user as the PHP package's
HasKeyringdoes on Eloquent'supdatingevent. Callprotection::guard()where you save users, andaddress_reserved()where you set an address. changing()reaches what its future awaits, not a task it spawns.- Deleting a user. Call
user_soft_deleted()oruser_deleted()where you delete users, never from inside a lock Keyring holds. Both refuse a user of any type but the provider's before touching anything. Each tries every step whatever happened to the one before and returns the first failure, so calling it again finishes the job, where the PHP package's hook stops at the first exception.
Console Commands
- Their messages go to stderr through laravel-rust's console, and
keyring:prunenames each table rather than each model (Pruned 3 [keyring_devices] records.). keyring:sign-outnames a user by theirmail_address()and ID, where the PHP package reads the username attribute, and only takes an ID made of digits.keyring:importreads Fortify's columns from the user provider's table, assession_user_typenames it, or the one--tablenames, warning that it files every row underauthenticatable_typewhen that's another table. It decrypts them with the application key, where the PHP package asks Fortify for its encrypter. It can't read Fortify's config, so a secret that was never confirmed needs--fortify-confirm(or--unconfirmed). A passkey it imports that can't sign in here (an Ed25519 one, say) is listed with the PHP package's warnings, namingKeyringConfigwhere they sayconfig/keyring.php. It counts as refused when the crate couldn't verify with its key, a little stricter than the PHP package. An AAGUID is taken in its 36-character form alone, andpublic_keyis written by serde_json, which reads back the same on both sides. There's no "Register … first" check for passkeys.keyring:installwrites nothing, as the migrations come with the provider and the config, the provider and the actions are your Rust code. It prints thewith_configfor what was picked and what's left to do, asks nothing, and has no--force. With an authenticator app, passkeys or security keys picked, it requires a second factor unless--optional-second-factor: it printsenrollment_urlset to/settings/security, and awith_middlewarethat appendsRequireEnrollmentto thewebgroup.- There's no
canSweep()orMissingMigration, as the migrations always run.sessions.sweep_everyis aDuration, so the only settings to warn about are zero and over 12 hours, which the provider logs once a day andkeyring:sweepsays as it runs.
Services for Your Own Code
Sessions::sign_out_everywhere()ends sessions asrevoked, with noSessionsRevoked, as the PHP package'ssignOutEverywhere()without a reason does. There's nobecause().still_signed_in()is given no session, so a user who followed their verification link, where registration hides who has an account, answersfalse.sign_out()doesn't follow a record another request moved the session to, and returns the user for your route to answer. Itsonly_this_browserleaves the remember token alone, aslogoutCurrentDevice()does, by signing the browser out the way impersonation does: it relies on laravel-rust's privateremember_webcookie name, and leaves the request'sAuthholding the user until the request ends, so only use it where you answer straight away.revoke()says whether a session ended and refuses one that isn't the user's, where the PHP package's returns nothing and doesn't check.list()gives the route's JSON.StepUp::unless_met()with a level asks for that level afresh, asRequireAssurancedoes. A guest isabort_with(401), and bad arguments are a plain error.- There's no
Keyring::factor()returning a factor, as there's no public factor type.SessionAssurance::since()andprovedSince()aren't there. RegisteredSession(fromSessions) andevents::RegisteredSession(in events) are different types.UserKeyringis what the user's sign-in methods were when it was loaded: load it again after changing them, as the PHP package'srefresh().
Test Helpers
testing::fake(&app)replaces an earlier fake rather than returning it, and its assertions with a count are_timesmethods.InteractsWithKeyringworks on eachTestRequest, afteracting_as, not on the test case, so a level or authenticators with a time go throughwith_proofs().- The instant timebox is
testing::instant_timebox(&app), not automatic. - Factory states are builders ending in
create_for(user_id). VirtualAuthenticator::eddsa()makes keys this crate refuses.FakeIdentityProvidergoes insso.providers(provider(name)forregister()) and isserve()d in the test, one at a time, with noHostResolverfake.KeyringConformanceis a builder that returns a report rather than a trait of test methods, acknowledges dangerous steps and unchecked routes withacknowledge_dangerous_steps()andacknowledge_unchecked_routes(), and doesn't check that a registry returns what it revokes or bcrypt's half of the 64-character password check (laravel-rust only hashes with bcrypt).
What laravel-rust Would Need
What the crate works around, and the laravel-rust API that would let it match the PHP package:
| Missing | What It Would Give | What the Crate Does Instead |
|---|---|---|
Auth::logout_current_device() |
Signing a browser out without a new remember token, as Laravel's SessionGuard::logoutCurrentDevice(). |
Auth::logout, signing out the user's other remembered browsers too. |
Session::destroy(id), or a session handler you can resolve |
Removing an ended session's data at once. | Leaves the record's check to sign the browser out on its next request. |
Auth::via_remember() |
Knowing how the user was loaded, as Laravel's viaRemember(). |
AuthenticateSession tells a remember cookie's sign in by the session ID changing. |
Laravel's Login and Logout events, or a hook before Auth::login writes the session |
Writing a sign in's record and device alongside it, and seeing your own sign out as it happens. | Writes them after, and notices your sign out once the handler returns. |
A public cookie::queue() |
Queuing a cookie from code that doesn't return the response, as Laravel's Cookie::queue(). |
Keyring's cookies go through a request extension AuthenticateSession attaches. |
| Knowing the guard queued its remember cookie | Recording a session you sign in with "remember me" as remembered, as the PHP package's recallerQueued(). |
Records it, but not as remembered. |
Session::previous_url() from the Referer |
Laravel's url()->previous(), which tries the Referer first. |
Reads the Referer itself, and writes _previous.url itself for an Inertia visit. |
Redirecting an InvalidInput back at any status |
Laravel's ValidationException redirects back whatever the status. |
Gives a browser's refusal a 422 (a lockout's 429), marked by SecurityHeaders. |
->block() on a route |
Taking the session lock for a route. | sessions.block, which BlockSession reads. |
| Different parameter names at one place in two paths | /user/authenticators/{factor} and /user/authenticators/{authenticator}. |
Every authenticator route uses {factor}. |
| Route parameter constraints | A pattern for a parameter, as Laravel's ->where('session', '[0-9a-f]{64}'). |
A middleware of Keyring's own ahead of the fresh check answers 404 for anything not shaped like a handle. |
| Middleware by name, with parameters | A setting that lists middleware, as keyring:aal2,device-bound in the PHP package's impersonation.middleware and changes_middleware. |
impersonation.requires_aal2 and fresh_for, and changes_fresh_for. |
| A route's other middleware | RequireEnrollment saving the page with what a RequireAssurance on the route asks, as Laravel's Router::gatherRouteMiddleware(). |
Saves the page with its own requirement. |
| Locking the user's row, or knowing their table | The PHP package's RowLock::hold($user). |
A cache lock on the user, and a row lock on the table session_user_type names for session moves, sign ins kept to sessions.max and sign-in method changes. |
A limiter with decay windows, lock keys and availableIn() |
Rate limits counted as Laravel's RateLimiter counts them, rather than a token bucket. |
Keeps its own counts in the cache. |
cache::forever() |
Values that never expire. | The throttle's marks last ten years. |
Laravel's Failed, Lockout, PasswordReset, Registered and Verified events |
Listeners built for Laravel's events keep working, and the verification email goes through Registered. |
Dispatches its own events alone. |
The current request in a listener, as Laravel's request() |
The security log and emails reading the address and browser from anywhere. | AuthenticateSession fills a cell at the start of each request, through laravel::once(). |
A public way to ask whether a user type derives MustVerifyEmail |
The security emails and enrollment checking verification. | Reads laravel-rust's hidden registry (laravel::auth::__VerifiedUser) through the inventory crate. |
ULIDs that go up within a millisecond, as Symfony's Ulid |
Ordering two log entries made in one millisecond. | Makes its own for the log. |
An updating hook on the user, or on a provider's save |
Checking protected attributes and reserved addresses on every save, as HasKeyring. |
You call protection::guard() and address_reserved(). |
Reading a user's address from Authenticatable |
A pending login ending when the address changes, without an action to read it. | Reads it through ChangesEmails or email_for_verification(). |
| Building a queued email in the worker | An email that can't be built failing in the worker. | Reports it and carries on. |
| Carrying a session over to a new password hash | Leaving the user's other sessions signed in, so sign_out_others: false works. |
Every other session is signed out on a new password. |
| Signing URLs as Laravel signs them, and relative to the site | Links either side signs opening on the other. | Signs and checks verification and report links itself. |
Reset tokens in Laravel's password_reset_tokens table |
Reset links either side sends working on the other. | Keeps the tokens in that table itself. |
A Registrar handle on the auth config |
A package marking its own verification page. | You call http::verification_page() in with_auth. |
A public Session::discard(), the ID the browser sent, and taking back a queued cookie |
sessions.overlapping_requests, Keyring's own StartSession. |
Not ported. |
A translator and an application locale, as Laravel's __() |
Translating Keyring's messages. | English only. |
A test client that keeps cookies and the session between requests, a public Application::services(), an HTTP client fake that falls through, runtime config changes in a test, and the routes' auth in the route table |
InteractsWithKeyring, Keyring::fake() and KeyringConformance working as the PHP package's do. |
The test helpers' differences above. |
| A route's URL by its name, from anywhere | Keyring's URLs following a prefix or domain your application gave its routes. | Its own prefix and domain settings. |