Differences From PHP

On this page

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, Registered and Verified aren't dispatched. Keyring's own events are the only ones.
  • sessions.overlapping_requests. Keyring's own StartSession, 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 Password factor's rehash() 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. EdDSA in webauthn.algorithms is 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, VerifyFactor or CompleteAttempt. They're fixed places in the crate's code rather than steps.
  • A second passkey factor that signs in alone (WebAuthn::passkeys()->as(...)). webauthn.keys factors 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 HasKeyring trait. 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, and user_deleted() or user_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's logoutCurrentDevice() 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_web cookie, because Auth::logout would change the impersonated user's token for something the impersonator did. Only impersonation does this: it relies on remember_web, a cookie name laravel-rust keeps private, and it leaves the request's Auth holding 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: false can't keep the others. Their records end at once anyway, as password_changed, with a SessionEnded for each, and each browser gets the signed-out 401 on its next request. sign_out_others only 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's guest middleware sends it where Laravel's RedirectIfAuthenticated does: / unless the application calls redirectUsersTo().
  • The session lock. A request that waits the full 10 seconds for the session lock gets a 500, not a 423. With the cookie session 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 ChangesEmails action, or for a user type that derives MustVerifyEmail its email_for_verification(), since laravel-rust's Authenticatable doesn'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_failed entry is a refusal on the account, written security_log.refusals times an hour at most, where the PHP package writes every one.
  • When FactorFailed fires. After the failure is counted, so a listener that fails can't keep it from counting. The PHP package dispatches it before. CloneSuspected and the quiet refusal's Lockout likewise, still in the PHP package's order.
  • Your own sign out. Your auth.logout() is noticed by AuthenticateSession once the handler returns, so only on routes in the web group. 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 always logged_out. There's no Sessions::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 database session driver moving a session to a new record and a sign in when sessions.max is set, also take the PHP package's row lock, SELECT ... FOR UPDATE on the user's id in the table session_user_type names, 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 IntegerId bound): the tables' authenticatable_id columns are big integers, as the PHP package's morphs() 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's recallerQueued()). It gets no remembered_session cookie, 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(), not Keyring::require(). devices.trusted_policy, which stood in for one, is gone: a closure reads trust from attempt.device().
  • Steps are values given to the provider's pipeline(), not class names the container builds, named by Step::name() (their type's own name without its path by default, as the PHP package names a step by its class) and the constants in pipeline.
  • Steps of your own only run between VerifyFactor and CompleteAttempt. 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() and dangerously_remove() only take EnsureNotRiskLocked and DetermineRequirement (and the steps that aren't mandatory). EnsureNotThrottled, VerifyFactor and CompleteAttempt can't be changed, even dangerously. Steps are named by their short names (EnsureNotRiskLocked) in dangerously_changed_steps(), the warning (to tracing, once at boot) and VerificationRefused::skipped. The log entry's skipped is 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 DetermineRequirement dangerously removed, or a replacement that sets no requirement, a sign in is asked what the policy asks, where the PHP package's never completes. KeyringConformance fails until each dangerously changed step is acknowledged with acknowledge_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 DetermineRequirement has run, not the PHP package's Factor, Authenticator or Verification objects.
  • 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 FactorCheck doesn't.
  • RequireAssurance's confirm asks for the whole level afresh, where the PHP package's unlessReached() 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's keyring:aal1 does. 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

  • RequireEnrollment and RequirePasswordChange know Keyring's own routes by the handler of the route the request matched (its path under laravel_keyring::http, from std::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_except and password_change_except take paths, a * matching anything, where the PHP package's take route names.
  • The requirement a page is saved with for continue is the middleware's own. A RequireAssurance on the same route isn't gathered into it, as the PHP package's toCarryOn() gathers keyring:aal2, since laravel-rust doesn't let a middleware see the route's other middleware. A user who enrolls enough for RequireEnrollment but not for the route's RequireAssurance is handed the page, and RequireAssurance sends 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 Detours keeps it.

Managing Authenticators

  • The routes are there once features.manage_authenticators turns 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 for http::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 and app.name by default), and the user's mail address as the account name (a passkey's user.name too), or the user's ID for one with no address, since laravel-rust's user doesn't say its username. The QR code is the qrcode crate'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 derives MustVerifyEmail waits for a verified address, and with registration on, whether addresses are verified at all is whether the provider was given verify_emails() with features.email_verification on, where the PHP package asks whether the model implements MustVerifyEmail. Enrolling then fails with a server error naming what to change.
  • The password checked for adding or removing a factor, and a proof, dispatch Attempting and FactorVerified as a challenge's answer does, besides the PHP package's FactorFailed, Lockout and AccountLocked.

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() and deviceBound() 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() or authenticators() (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 when identified_by includes the username field.
  • IdentifiesUsers::verify and ChecksProofs::verify answer whether the proof holds rather than with a Verification.
  • Keyring doesn't validate their fields (identificationRules(), rules(), enrollmentRules()): the factor does, answering InvalidInput. A primary factor's sign in validates in IdentifiesUsers::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 (challenge is []). An Identified::by(user, id) naming a row that isn't the user's confirmed authenticator of that factor is taken as nobody found, after stall().
  • Enrolls::confirm gets what begin kept without the keys starting keyring., which are Keyring's.
  • A factor's key, and webauthn.keys' keys, name it across the whole process, as code factors' do.
  • With no factors set, the crate has the password, authenticator apps, recovery codes and passkeys, where the PHP package's Keyring::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 the keyring limiter (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 PHP CodeFactor subclass's categories() is given the authenticator. One that proves nothing stops the application booting.
  • Its own limits(), a FactorLimits, replace those of the four of per_ip, per_account, consecutive and consecutive_elsewhere it gives, where a PHP limits() returns any limits at all.
  • Its sender's new_authenticator() returns the name, secret and meta to 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.limiter to 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() or email_codes.mail_using replaces it, the first before the second. A user with no address (mail_address() is None) is sent nothing.

Passkeys and Attestation

  • Key algorithms. webauthn.algorithms is 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 with ed25519-dalek directly would mean redoing the whole assertion and registration checks outside webauthn-rs-core, which isn't a small or safe addition. So EdDSA in 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_roots are trusted for every model, as the PHP package's own ConfiguredRoots does, unless webauthn.trusts gives 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-u2f statement 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 model aaguids lists.

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 Arc in devices.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 with Assessment::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.max fails, the sign in fails. On the database driver 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, a sessions.connection of 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_sessions on the default connection, so a sessions.table or connection of 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 to sessions.extend(), not a closure for the manager, and is given the reason and the time with each call. It never announces, so there's no AnnouncingSessionRegistry to 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_guest lists 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's fullUrl() sorts its parameters.

Impersonation

  • Who may impersonate whom is given to the provider (allow_impersonation_when()), not a global Keyring::allowImpersonationWhen(). The closure has the PHP one's shape, the impersonator and then the user.
  • impersonation::impersonate() and stop_impersonating() take the request's Auth, Session and Request. impersonate() asks what impersonation.requires_aal2 and fresh_for ask before it starts anything, and returns ImpersonationStart::StepUp with the step-up's answer for you to send, where the PHP package leaves that to the route's middleware.
  • Starting asks impersonation.requires_aal2 and impersonation.fresh_for rather 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 in sessions.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::Myself is the PHP package's Self, a name Rust keeps for itself. Its value is self.
  • 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's name attribute, 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_web cookie as it lets the user go, which Keyring can't stop: the admin keeps remembered_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 SsoProvider values in sso.providers. A driver of your own implements sso::IdentityProvider and is registered with sso.extend(), given the provider's SsoProvider (anything else it reads in options) rather than an array and a name. Its callback is the query string as a map rather than the request, and a failure is an SsoFailed inside the error.
  • sso::provider() and providers() give a ConfiguredProvider (its name, label, freshness and whether it can reauthenticate) rather than the driver itself.
  • sso::start() and sso::complete() take the session, and a provider that isn't configured is a 404 from them, where the PHP package throws UnknownSsoProvider. sso::start() refuses Keyring's own purposes (login, link, confirm), which the PHP package's start() 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.
  • freshness is an SsoFreshness, so the PHP package's false for never has no spelling here.
  • RSA public exponents are limited to what the rsa crate 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 OAuth2 and implements IdentityProvider, passing its endpoints to authorization_url() and tokens(), and an OpenID Connect driver keeps an Oidc and implements OpenIdConnect. 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 with trusts_key() rather than by overriding signedByOneOf(). A driver built on Google, or another of Keyring's, passes each of that driver's hooks on itself. checkCallback(), authorizationParameters(), exchange(), tokens(), mayFetch() and endpointIn() have no hook. SignedToken isn't public, so a driver checks an ID token with oidc::verify(). oidc::userinfo() has no PHP counterpart, and a userinfo answer that's a JWT isn't read.
  • Keyring::linkRootUsing() is the provider's link_root_using(), and FakeIdentityProvider is in laravel_keyring::testing (see Test Helpers).

Signing In From Your Own Routes

  • sign_in::attempt() takes a SignInWith rather 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. With features.sso off, Sso is a 404.
  • A browser someone is signed in on is sent home by attempt(), 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 an Impersonating error, a 403, where the PHP package's ends the impersonation first. It takes Verified::password() or Verified::authenticator(id), one of the user's own sign-in methods, where SignIn::as() takes any Verification.
  • There's no keyring-login-options limiter 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's keyring.domain has no counterpart.

Pages and Responses

  • Keyring renders through Inertia only with the crate's inertia feature, 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 a Response.
  • KeyringResponse covers the PHP package's response contracts but FailedResponse and LockoutResponse: a refusal is laravel-rust's InvalidInput error, which you render your own way with Errors::render.
  • A browser's refusal on fields is given a 422 so laravel-rust redirects it back. The redirect doesn't show it.
  • laravel-rust asks an application whose user type derives MustVerifyEmail to mark its verification page, which a provider can't do, so you call laravel_keyring::http::verification_page::<User>(auth) in with_auth.

Routes

  • http::routes() registers under KeyringConfig::prefix and domain itself, 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-referrer still hold, but Keyring's URLs don't follow the group's prefix.
  • There's no middleware setting: with routes off you wrap http::routes() in middleware of your own.
  • A domain has to be a plain host, and a prefix a plain path: a {placeholder}, a query, a fragment or whitespace stops the application booting.
  • sessions.continue_as_guest lists Keyring's own pages with their prefix.
  • With sessions.middleware off, Keyring's own routes are a 500 naming AuthenticateSession until you add it.
  • WebAuthn origins don't follow domain, as in the PHP package.
  • ValidateSignature names a refused link by the name it's given, as laravel-rust's routes have no names. There's no keyring.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.respond is a plain fn(&Risk, Checkpoint) -> Action, which can't capture anything.
  • Assessment carries the user as user::<U>(), their ID and type, the attempt as the events see it, the browser's device ID, and on a request the session as events::RegisteredSession, rather than the models themselves.
  • risk::assess() and risk::enforce() are public, for a pipeline step that replaces AssessRisk. 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, and Assessment::for_user() outside a sign in.
  • Locks are in the default cache store. There's no risk.store.
  • A Finding's and a Risk's score is a u32, where PHP's is an int that could be negative.
  • BreachedPassword asks Have I Been Pwned's range API through laravel-rust's HTTP client, as Laravel's NotPwnedVerifier does. There's no UncompromisedVerifier to 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: FactorFailed has the username typed, Lockout and Attempting the factor, and ProtectionBypassed the user who made the change.
  • Events whose PHP payload is a model carry plain values (an Authenticator with its ID, factor and name; an Attempt with its purpose and verifications). FactorFailed, RecoveryCodeUsed and CloneSuspected carry the user the PHP package gets with authenticator->user().
  • NewDeviceSignedIn::revoke_url() takes the days as an Option<u32> and returns a Result, as the link can't be signed without an APP_KEY.
  • DeviceRevoked carries the device's ID and name, not its model.
  • VerificationRefused carries the user beside the attempt, and the skipped steps' short names.
  • ProviderIdentityAccepted carries the Identity with its request's secrets. Identity::without_secrets() is the PHP package's withoutSecrets(), for a listener that keeps it.

The Security Log

  • An entry the table won't take, or every entry with security_log.enabled off, is a tracing event under the keyring::security_log target, with the PHP package's message (Keyring: {type}) and context, rather than a line on a log channel. There's no security_log.channel.
  • tracing has no notice or critical, so notice goes out at INFO and critical at ERROR, 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_using replaces every other kind's at once.
  • Emails a flow needs (verification_code, confirm_email_change, email_change_notice, email_address_in_use and already_registered) aren't kinds: each has a method of its own on notifications, 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 no createUrlUsing(): 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 to null gets a MissingNotification refusal, and a Rust app turns the flow off instead. Only the reset and verification links carry the user.
  • when is 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 a sync queue can't make a locked account's answer slower than a name nobody has.
  • Each kind's count goes by authenticatable_type and 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's ResetPassword and VerifyEmail and the PHP package's AlreadyRegistered. There's no Registered or Verified event to send them through. The reset tokens' table is always password_reset_tokens, the table of a new Laravel app, which your migrations create.

Passwords

  • Password rules. PasswordRules is a builder your actions call (PasswordRules::new().context([..]) at registration, PasswordRules::for_user(&user) for a change or a reset, then check() or validate()), not a list of Laravel rules. .min() and .max() stand in for the closure that adjusts the PHP package's Password rule, 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 the name, 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 PasswordRules it breaks.
  • The features start off. Registration, password resets, changing the password and email verification are off until you turn them on in features and give the provider your actions, where the PHP package's config turns them on. One that's on without its action, email verification without verify_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's find_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 in taken().

Email Changes and Reserved Addresses

  • Your ChangesEmails action reads and saves the address, where the PHP package reads and force-fills the model's email attribute. 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() asks find_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.php writes 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 HasKeyring does on Eloquent's updating event. Call protection::guard() where you save users, and address_reserved() where you set an address.
  • changing() reaches what its future awaits, not a task it spawns.
  • Deleting a user. Call user_soft_deleted() or user_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:prune names each table rather than each model (Pruned 3 [keyring_devices] records.).
  • keyring:sign-out names a user by their mail_address() and ID, where the PHP package reads the username attribute, and only takes an ID made of digits.
  • keyring:import reads Fortify's columns from the user provider's table, as session_user_type names it, or the one --table names, warning that it files every row under authenticatable_type when 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, naming KeyringConfig where they say config/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, and public_key is written by serde_json, which reads back the same on both sides. There's no "Register … first" check for passkeys.
  • keyring:install writes nothing, as the migrations come with the provider and the config, the provider and the actions are your Rust code. It prints the with_config for 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 prints enrollment_url set to /settings/security, and a with_middleware that appends RequireEnrollment to the web group.
  • There's no canSweep() or MissingMigration, as the migrations always run. sessions.sweep_every is a Duration, so the only settings to warn about are zero and over 12 hours, which the provider logs once a day and keyring:sweep says as it runs.

Services for Your Own Code

  • Sessions::sign_out_everywhere() ends sessions as revoked, with no SessionsRevoked, as the PHP package's signOutEverywhere() without a reason does. There's no because().
  • still_signed_in() is given no session, so a user who followed their verification link, where registration hides who has an account, answers false.
  • sign_out() doesn't follow a record another request moved the session to, and returns the user for your route to answer. Its only_this_browser leaves the remember token alone, as logoutCurrentDevice() does, by signing the browser out the way impersonation does: it relies on laravel-rust's private remember_web cookie name, and leaves the request's Auth holding 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, as RequireAssurance does. A guest is abort_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() and provedSince() aren't there.
  • RegisteredSession (from Sessions) and events::RegisteredSession (in events) are different types.
  • UserKeyring is what the user's sign-in methods were when it was loaded: load it again after changing them, as the PHP package's refresh().

Test Helpers

  • testing::fake(&app) replaces an earlier fake rather than returning it, and its assertions with a count are _times methods.
  • InteractsWithKeyring works on each TestRequest, after acting_as, not on the test case, so a level or authenticators with a time go through with_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.
  • FakeIdentityProvider goes in sso.providers (provider(name) for register()) and is serve()d in the test, one at a time, with no HostResolver fake.
  • KeyringConformance is a builder that returns a report rather than a trait of test methods, acknowledges dangerous steps and unchecked routes with acknowledge_dangerous_steps() and acknowledge_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.