Repository navigation
Conversation
…ng each request against its record
… as the readme asks
…rgest int64 on postgres
… lockout and sign ins at once
…itself, so register boots it
…ties when linking and primary keys shared with code factors, with the rust crate's missing tests
…ers, answer every refused sign in at once and check setups as php does
… ends and refusals, and end it on the app's own sign ins and sign outs
…ation, offer impersonation, and print settings that boot
…nd once the overlap has taken its cookies off
…zero keep-for at its default, and match php's sweep and import edges
…gs, and EveryoneSignedOut
… messages and results
…t only what's really missing
… admin after an impersonation starts
…nd the notifications comment
…feat/laravel-go-support # Conflicts: # CHANGELOG.md # contract/README.md
…here mail apps look
…in link's root, prefix and form
…y signs in where it was sent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Go port of Keyring for Laravel for Go (
go/keyring, on go.laravel.com v0.1.1). It uses the same tables, stored data and JSON as the PHP package, so one database works with both. Also in this PR:go/contract-app), whichcontract/bin/run-goholds to the HTTP contract;go/keyring/keyringtest);go/starter-kit), mirroringrust/starter-kit;docs/go.Stacked on #154, so the base is
feat/laravel-rust-support. Retarget tomainonce that merges. The base is merged in up to its latest commit (which brought #157, #159 and #160 from main). No PHP or JS package code changes on this branch.What's in: all 14 steps of the port
AllowSignInWhenand the pipeline stepsjoseandhostsleaf packagesAttempt,AttemptSSO,SignInAs,LinkedSSO,LinkNewAccount), and primary factors of the app's own at/login/{factor}keyring:prune,keyring:sweep,keyring:sign-out,keyring:importandkeyring:install, with the keep-for settings, scheduling, andEndUnsavedSignInskeyringtest:State
contract/bin/run-gopasses every contract file: 292 tests in 27 files, nothing pending, also with--randomize.contract/bin/run-phppasses the same 292.go test ./...passes in all three modules, on SQLite and on Postgres. gofmt, vet andgo mod tidy -diffare clean.goandgo (pgsql)jobs, and the js job builds the Go starter kit. Like the rest of CI they skip on drafts, so they've only run locally.Not ported: security keys and attestation formats other than
none,activity(),recordIpsUsing(), translations and Argon2. Some session and step-up services can't be called from the app's own code yet.docs/go/differences.mdlists everything.Running the tests
Decisions for Charlie
These are calls made while working alone. Each takes the option closest to the PHP package, or to the Rust crate where PHP doesn't apply. A few of them (the step-up idle fix, the hold loop fix, the
end_parkedlock gap) are worth taking back to PHP and Rust as well.All decisions (140)
Calls made while working alone, each the option closest to the PHP package (or the Rust crate where PHP doesn't apply). Each is easy to revisit.
Pending contract tests (step 3). A contract file goes on run-go's list once every test in it that the steps so far can pass passes; the rest are named in run-go's
pendinglist with the step that passes them, rather than the file waiting until step 7.Alerts are shown to one sign in only (step 3). Marked seen only if still unseen, stricter than PHP, which can show the same alert to two sign ins at once.
noteRequestis global middleware (step 3). So entries from any route carry the request ID, IP and user agent, as PHP'srequest()does anywhere. Itsdb.Concurrentbranch means a test that makes a request while holding a savepoint on the client's context hangs rather than failing at once.Overlapping requests ported (step 4), though the Rust crate skips them, since they're PHP's default and without them a double click signs a browser out. It works around Laravel Go (a wrapped store, nameless cookies,
Sec-Fetch-Siteremoved so the CSRF token decides); see What Laravel Go Lacks for what would make it clean.The user's row lock waits 5 seconds (step 4), as the Rust crate, where PHP waits as long as the database does, and takes
FOR NO KEY UPDATEon Postgres. A request that can't get it in time answers 500 (a confirm then signs the browser out). There's no setting to turn the row lock off for apps that don't share their database with PHP.A failed device-trust cache mark still ends the trust and answers 500 (step 4), where PHP stops before the update.
The owner's right code clears an attacker's failures in a row with devices off (step 5), as PHP's
FailureCounts::succeeded(): with devices off (the default) every browser counts in onefailures, so someone with the password can guess four codes a minute indefinitely while the owner keeps signing in (about 1.7% a day with the window at 1). With devices on, the owner's browser clears onlyknown_failures. Kept for parity; a product call for all three ports (e.g. not clearing failures in a row on a factor that can't start a sign in).A right code is spent before the "unavailable" refusal (step 5), in PHP's order; the Rust crate refuses first.
The new-device email goes through the queue (step 6), as PHP's
ShouldQueueAfterCommit. Laravel Go defaults to thedatabasequeue wheneverDATABASE_URLis set, so an app without a worker (orQUEUE_CONNECTION=sync) sends nothing; theNotificationsdoc says so.The email has PHP's lines without Laravel's notification layout (step 6), as the Rust crate; Laravel Go has no such template.
A 404 on someone else's device says
Not Found(step 6), not PHP's "No query results for model [Keyring\Models\Device]", which names a PHP class.A typed name ending in
|knownshares the known browser's limit keys (final review), in all three ports: anyone can post five wrong passwords asvictim@example.com|knownand the owner's first typo from their own device answers 429 (the right password still signs in, nothing is locked for good). The ports share cache keys, so the fix (e.g. the known flag before the name) needs the PHP package and the Rust crate changed together. Not changed.DELETE /user/devices/{device}still 404s on a device already marked signed out (final review), as PHP's->active(): after a sign out that failed part way, only the report link or the sessions list can finish it.Limits.GuestFormsis a new setting (final review), as the Rust crate'slimits.guest_forms, so the contract app can raise guests' form limit without raising signed-in users'.Go CI jobs added (final review),
goandgo (pgsql), mirroringrust/rust-databases; they've only run locally throughbin/ciso far.WebAuthn is our own leaf package, not go-webauthn (step 7).
go/keyring/webauthn(~700 lines, standard library only) runs webauthn-lib's ceremony steps in their order with its readings of base64, client data and authenticator data, so what passes and what's refused matches the PHP package. go-webauthn'sprotocolwould have been a dependency tree, its own credential and session types to convert from webauthn-lib's JSON at both edges (as the Rust crate had to with webauthn-rs), a clone reported as a flag rather than a refusal, and different strictness on base64 and client data. Our package also checks EdDSA, which the Rust crate couldn't.Passkey records are written back as webauthn-lib writes them (step 7): its keys in its order, nulls left out, fields it doesn't know dropped, IDs re-encoded as unpadded base64url, the AAGUID lowercased, as PHP does on every sign in. The Rust crate keeps unknown fields and the stored order; PHP is the reference here.
Cross-origin answers are refused (step 7), as the Rust crate's audit fix:
crossOrigin: truewith notopOrigin, and atopOriginofnull, which webauthn-lib (with no top origin validator) lets through. Stricter than PHP.Passkey settings are checked at boot (step 7): origins and the RP ID (the Rust audit's fix) and unknown algorithm names, where PHP throws a LogicException on the first ceremony.
A passkey alone's failures on an account are capped refusals (step 7), as the Rust crate's audit; PHP writes every one.
FactorFailedgainedIdentifyingto say so.CloneSuspectedis dispatched when the failure is counted (step 7), beforeFactorFailed, as the Rust crate; PHP dispatches it from inside the check. Same entries, same order.A failed challenge answer doesn't save the attempt (steps 5 and 7), where PHP's VerifyFactor saves it: the passkey options it held are spent on the server anyway, so the outcome is the same.
Only
/login/passkeyand its options are routed (step 7), not PHP's/login/{factor}for any primary factor; the names are PHP's (keyring.login.options,keyring.login.factor). Other primary factors come with step 13.Factors.Passkeysis on by default (step 7), as the Rust crate'sfactors.passkeys; PHP has whatever factors the app lists (its contract app lists passkeys).A passkey alone loads its user with
Find, notFindForLogin(step 7), as the PHP package (the authenticator's owner relation, no login scope) and the Rust crate do: an app that hides suspended users only fromFindForLoginstill lets them in with a passkey. Settled in step 10b: kept, as PHP, sinceAllowSignInWhenis where PHP keeps such users out of every factor, a passkey alone included (tested).A user handle's oldest key is found by
created_at, thenid(step 7), a tie-break PHP'soldest()leaves to the database. An AAGUID is read only in RFC 4122 hex (Symfony'sUuid::fromStringtakes base32 and base58 too).Registration and email verification start off (step 8a), as the Rust crate starts its four account features, where the PHP package's config turns them on: each needs something of the application's first (the action, or a user type and users that can verify).
A user type verifies its address only with
Features.EmailVerificationon (step 8a). PHP asks whether the model implementsMustVerifyEmail; Laravel Go reads anEmailVerifiedAtfield every new user type has, so taking that alone would stop every notice to unverified users of apps that never verify. With the feature on, the type must have the field and the users anauth.EmailVerifier, which Register checks. A Go app sharing users with a PHP app that verifies should turn it on.The sign-in gate follows PHP's
hidesRegisteredAddresses()(step 8a), registration on andRevealTakenoff, where the Rust crate has a switch of its own (verified_before_sign_in, on by default) so it can hold unverified users back with registration off. A Go app sharing users with a PHP app that registers should turn registration on too.CreatesNewUserstakes and gives maps (step 8a), as PHP's array and the Rust crate'sInput:Validate(r)validates the request (passwords already in NFC) and returns whatCreateneeds, and Keyring reads the address from it underConfig.Email. Taken addresses are looked for in the user model's table, or through an optionalTakenthe action implements (the Rust crate'staken()), not the provider'sFindForLogin, which may hide accounts that still hold their address.Config.Emailis new (step 8a), the PHP package'skeyring.email, apart fromUsername, bothemailby default.A unique violation from
Createis looked at again (step 8a, review), as PHP: taken by then, it's answered as taken; otherwise it's some other index's, reported and answered the same with nothing sent where registration hides addresses, and a 500 where it reveals them. The Rust audit answered every violation as taken, which would hide a broken unique index of the application's behind "taken".The verification email is Laravel's lines without its layout (step 8a), subject "Verify your email address" as PHP's Laravel sends it (the Rust crate says "Verify Email Address"), and
already_registered's reset line is the Rust crate's plain "Forgotten your password? Reset it here: URL" where PHP's is Markdown.Notifications.AccountMailreplaces either.Mail after a hidden registration, and the reset link, go from
r.Background(step 8a, review), as PHP'sdefer()and the Rust crate'stask::background; sent there with the mailer, not queued (see the account emails below).r.OnFinishheld the next request on a kept-alive connection until the mail and theRegisteredlisteners were done, which showed a free address from a taken one.A taken address is mailed at the address its account has, and only when it's the one typed (step 8a, review), stricter than PHP and the Rust crate, which mail the typed address. On a collation that ignores accents (MySQL's
_ai_ci),victim@exämple.comfindsvictim@example.com's account, and the typed mailbox would learn that address is registered, with a notice allowance of its own. Now the account's row is loaded (Config.Email's column, orFindForLoginfor an action withTaken), the notice is counted under its normalised address, and nothing is sent if that isn't the typed address normalised. An address the action'sTakensays is taken with no account found for it gets nothing either, as there's no stored address to check it against.registeredandregistration-receivedname the login page by its route (step 8a), wherever the application placed Keyring's routes, as the Rust crate's fix.The 429 for another verification link uses the sign-in lockout's countdown (step 8a), "Too many login attempts. Please try again in N seconds." (
countdownMessage, "1 second" for one), as the Rust crate; PHP'sauth.throttlesays "seconds" always. However long is left, as PHP'sThrottle::exception(): never the lockout's "Reset your password" pastLimits.LongestLock(review).International hosts follow the URL Standard's bidi and joiner rules (step 7 review), as browsers do, where the lexbor PHP 8.5 ships skips them: a few hosts PHP takes (e.g.
1app.xn--6dbbec0c.co.il) stop Go at boot when passkeys are on. Passkeys need the host the browser hashes, so the browser's rules win.Password resets and changes start off (step 8b), as the Rust crate starts them, each needing its action (
ResetPasswordsWith,UpdatePasswordsWith), which Register checks; the PHP package's config turns them on. The actions take the input as a map, asCreatesNewUsersdoes, and save the password themselves.sign_out_others: falsestill ends the other sessions' records (step 8b), aspassword_changed, as the Rust crate does:auth.Sessionsigns out every session whose password fingerprint is of another hash, so they'd be signed out on their next request anyway, and ending their records now keeps them off the sessions list. The rest of signing out everywhere (a new remember token) waits forsign_out_others. The PHP package keeps them; the contract leaves it open.The session that changed the password is signed in again with
auth.Login(step 8b), so the guard's fingerprint is of the new hash, before it moves to a new record. Without it the guard would sign the browser out on its next request.A browser the guard let go of, whose record had already ended, is logged as
session_ended(step 8b), with the reason PHP's middleware gives (revokedafter a change or reset), for the record's user if they're still there: the PHP log has that entry, as its guard keeps no fingerprint and its middleware finds the record ended.A user with no remember token isn't given one when signed out everywhere (step 8b), where the PHP package's
cycleRememberToken()gives one (Laravel'sgetRememberToken()casts a null to"", which passes its!== null): no cookie carries a token the user doesn't have, and saving one waits on the user's row with no limit when the PHP side holds it (user_row_test.go). Sousers.remember_tokendiffers between the two after a reset or a change, for such a user alone.The reset email's subject is "Reset your password" (step 8b), as the Laravel the PHP package runs on sends it; the Rust crate says "Reset Password Notification", Laravel's older wording. Laravel's lines, without its layout, as the other emails.
A reset link's address is found through
FindForLoginwhen users sign in by it (step 8b), and otherwise byConfig.Email's column, thenFind, as Laravel's broker asks the provider by thekeyring.emailcredential; the Rust crate always asksfind_for_login, which can't find an address by another column.The hold's exceptions are route names (step 8b), as PHP's
routeIs(), so an application route with one of those names is let through too; the Rust crate matches Keyring's own handlers only.A reset unlinks identity providers ahead of single sign-on (step 8b), as the PHP package does whether the factor is registered, with
AuthenticatorRemoved, its log entry and its notice, which step 9a's removals share.The checks Rust's audit moved ahead of the action stay ahead of it (step 8b): the current password again, the held one, and one bcrypt can't take (with every rule of the user's
PasswordRules) are refused before the action runs, where the PHP package lets the action save and refuses after (unchanged) or leaves bcrypt's limits to the action's rules.A change's write rolls back with the user's row lock (step 8b) on PostgreSQL and MySQL when the action fails, as the PHP package's
RowLock::hold()transaction does, and then nothing that follows a save is done. On SQLite the write stands, and what follows it is done before the failure is returned, but only for a write the action made (never a hash another request stored meanwhile).A reset runs under the owner's lock (step 8b), as the Rust crate's, so of two resets with one link only one goes through; Laravel's broker takes no lock.
RequirePasswordChangetakes the reason as a string (step 8b),""for none, kept asNULL./enrolledin the contract app answered without asking for a second factor (step 8b): the hold tests navigate to it; since step 9b it's behindRequireEnrollment, as the PHP app's.Laravel's
email|max:255messages both show (step 8b): Laravel doesn't stop at the first rule a field breaks unless told tobail, so an address that's malformed and too long gets both, and one that isn't text "must be a string" and "a valid email address".Keyring creates
password_reset_tokenswhere it's missing (step 8b, review), in Laravel's schema (emailprimary,token,created_atnullable, whole seconds), from a Go-only migration,2026_12_03_000001_create_password_reset_tokens_table_if_missing, a name no PHP migrations table has. A PHP app gets the table from Laravel's first migration, a Laravel Go app from nothing, and without it resets can't send links and a change fails after its save. An app migration of its own that sorts before it (as the contract app's0001_01_01_000003_...) keeps the table it makes; one added later, sorting after, would fail on a database Keyring already gave the table. Rejected: failing Register, which can't look at the database.A reset is refused once the account's address has changed since it was looked up (step 8b, review), read again under the owner's lock: stricter than PHP, whose broker checks the token against the address of the user it loaded and saves whatever the row is by then.
The password actions run with a deadline under the owner's lock (step 8b, review): 2s before the 10s lock lapses, and the breach checks (Laravel's 30s, Keyring's 10s) wait at most until a second before it. A check that runs out is one Have I Been Pwned couldn't be asked about, as in PHP once its timeout is up: let through, or refused with
RefuseUnchecked. PHP waits the full timeout, under no lock for a reset and the user's row lock for a change.A browser that changes the password isn't brought back by "remember me" afterwards (step 8b, review), as with the PHP package (checked with a throwaway Pest test: remember, change with
sign_out_otherstrue or false, lose the session, come back: signed out), whose guard cookie keeps the old password's hash and, the others signed out, the old remember token. The Go port signs the browser in again without "remember me", which takes the guard's cookie back to the same effect; Keyring'sremembered_sessionmoves to the new record as PHP's does.The account emails are sent with the mailer from
r.Background, not queued (step 8b, review), as PHP: Laravel'sResetPasswordandVerifyEmailand Keyring'sAlreadyRegisteredaren'tShouldQueue, so PHP sends them in the request (or itsdefer()) and stores no link or token; only the security notices are queued (ShouldQueueAfterCommit).sendAccountMailusesmail.Send, so a reset link's token and a verification link never sit injobsorfailed_jobs. Every caller sends fromr.Background, whose goroutine starts at the call and is never waited on for the answer (not after it, as PHP'sdefer()runs), the open registration's link andPOST /email/verification-notificationincluded (PHP sends those two in the request, where a mailer failure is a 500): a failure is reported and the answer is the same.Beginning an enrollment counts against
Limits.Forms(step 9a), as the Rust crate's audit counts it, where the PHP package'sstore()route has nokeyring.throttle: beginning sends codes (9b) and does a key's work.Changes to sign-in methods take the owner's lock as well as the user's row (step 9a), as the Rust crate's
changes::holding(), where the PHP package takes the row lock alone: on SQLite, where there's no row lock, two changes would otherwise each find the account unfrozen.Making the default the default again keeps it (step 9a), as the Rust crate does it. The PHP package's
update()unsets every default, the authenticator's own fresh copy among them, then setsis_defaulton the model it loaded, which Eloquent finds unchanged and doesn't save, so the authenticator ends up not the default. A PHP fix (->filter(fn ($other) => $other->isNot($authenticator))) would bring the two together.A posted credential whose
id/rawIdisn't the attested credential ID is refused (step 9a), stricter than webauthn-lib, which stores the attested ID whatever the browser posted.A 404 for someone else's authenticator says
Not Found(step 9a), as for a device (step 6), not PHP's "No query results for model [Keyring\Models\Authenticator] …".Registration with managing sign-in methods and no email verification stops Register (step 9a), unless
AllowEnrollmentWhendecides, where the PHP package throwsEmailVerificationRequiredat the first enrollment.The QR code is
rsc.io/qr's, drawn as one path of squares (step 9a), 192 pixels across with no margin as BaconQrCode's, not its markup; the module's one new dependency (BSD, by the Go authors, no dependencies of its own). Laravel Go has no QR renderer, and writing one (Reed–Solomon, masks, version tables) wasn't worth it.Sign-in methods of factors Keyring for Go can't check aren't listed, renamed or removed (step 9a): a PHP app's
ssolink or emailed code is a 404 here until steps 9b and 12, as the PHP package's own routes are for a factor it doesn't register. They aren't left out of the rest, failing closed as PHP would see them (review fix): one that may be a factor (notrecovery,email-codeorsso; a security key, or a passkey with passkeys off) freezes the account forEstablishedAfteronce added, and keeps the recovery codes when the last factor Go knows is removed.A removal whose devices can't be distrusted isn't made (step 9a), as in the PHP package's transaction: nothing is removed, and nothing announced (review fix; it used to be announced with the failure returned).
Renaming or making the default one removed meanwhile is a 404 (step 9a), decided under the lock: the PHP package saves its stale copy, to no row, and answers that it did.
The first factor's recovery codes are decided and made under the lock (step 9a), where the PHP package makes them before: a set made meanwhile in another request is kept, rather than replaced by codes the user never saw saved, and the answer has no
recoveryCodesthen.SignInMethodsis the Rust crate's (step 9a): the PHP package leaves a settings page to read$user->keyring->all()andpresent()itself, which Go apps can't reach.Codes are sent with the mailer in the request (step 9b), as the PHP package's
VerificationCode(notShouldQueue) and the Rust crate send them: the user is waiting, and a queued one would keep the code in the jobs table. A mailer's or sender's error is the request's 500, with the new code already kept, as in both.An attempt a wrong code leaves out of guesses is saved (step 9b), an exception to steps 5 and 7's "a failed answer doesn't save the attempt": otherwise its page would carry on showing until the next answer. The guesses are counted on the server either way.
Register refuses what the PHP package refuses at first use (step 9b):
verification_codeinNotifications.Offwith emailed codes on (PHP'sMissingNotificationas the first code is sent), andLimits.Codesunder one orLimits.CodesPerunder a second with a code factor on (PHP would refuse every send). Codes are capped at 18 digits, as in the Rust crate.A code factor of the application's own is a struct with zero defaults (step 9b):
CodeFactor[U]{...}given toAddCodeFactor, as the Rust crate's builder, its sender an interface and making the new method an optional second one. It proves possession, or the address withSentToAnAddress; the Rust crate's own limits and other categories, and acredential_idfor the row, wait for an application that needs them.Emailed codes are off unless set (step 9b),
Factors.EmailCodesnil, as the PHP package has them only once registered (its contract app registers them, as the Go one now does).RequireEnrollmentfails closed without the session (step 9b), a 500 asRequireAssuranceandRequireFreshVerificationanswer, where the PHP package's would find no user and let the request through.RequireEnrollmentsaves the page with its own requirement alone (step 9b): Laravel Go doesn't tell a middleware the values of the route's others, so the docs say to give it the options of the route'sRequireAssurance. Otherwise a user adds what this one asks and is sent back by the other, which saves the page again with its own.A signed-in browser at a guest page goes where Laravel's
RedirectIfAuthenticatedsends it (step 10a): thedashboardroute, thehomeroute or the site's root, as the PHP package'sguestmiddleware, where the Rust crate (and Go until now) sends it tohome. Laravel's version also takes an unnamed GET route at/dashboardor/home, which Go can't look up, and an application changes it withredirectUsersTo(), which Laravel Go hasn't got: a Go app sharing users with a PHP app that calls it should name the route it points todashboard.A guest's redirect to log in from a signed-in route keeps Keyring's security headers (step 10a):
Referrer-Policy,X-Frame-Optionsand the rest, which the PHP package's answer lacks because Laravel's middleware priority runsauthahead ofAddSecurityHeaders. Stricter, on a redirect with no body; left as it is.Sessions.ContinueAsGuestrefuses an empty route name at Register (step 10a), where the PHP package treats a list it can't read as no routes, which a typed setting can't be.EndUnsavedSignInswaits for step 14 (step 10a): it's the Rust crate's own (the PHP package has none), about sessions that fail to save rather than pages, and needs every record move to say whether its session will be saved.A held user is let through to
PasswordChangeURL's page pastRequireEnrollment(step 9b, review): the hold comes first. In the PHP package and the Rust crate, a held user with no second factor loops:keyring.enrolledsends the password page to enroll, and the hold sends the enrollment page back to the password page. A three-port fix: PHP'sRequireEnrollmentand the Rust crate's should let that page through while the user is held, as Go now does.Wrong code guesses are read, compared, then counted (step 9b, review), as PHP's
CodeFactor::check()and the Rust crate: two guesses at once can both be checked against a count of four. The session lock bounds it for one session (a sign in's attempt or a user's enrollment lives in one session), but copies of a session, or two sessions enrolling, could each get a guess past the limit. Counting first (hit, then compare) would need all three ports to change together, since they share thekeyring:guesses:counts.An enrollment's code can get about nine guesses (step 9b, review): the guesses are counted for
EnrollmentsFor(15 minutes) from the first wrong one, which may have been at an earlier code, and a code lasts 10 minutes. A code begun again late in that window gets the guesses left in it, then, once the count lapses, five more: up to about twiceMaxGuesses. Still nowhere near a 6-digit code's million. As PHP and the Rust crate, whose counts the Go port shares.An application's own code factor's enrollment sends are limited per account only (step 9b, review),
Limits.CodesinLimits.CodesPerin the|signed-inbucket, as PHP'sThrottle::sending(): whoever is signed in chooses the destination (a phone number), so a paid SMS sender can be made to text other people's numbers, three every ten minutes per account. The docs should tell applications with paid SMS to limit by destination and IP in theirDeliver.The browser proof shares
crypt.EncryptStringwith authenticator secrets, with no purpose tag (step 9b, review), as PHP'sCrypt::encryptString(): theknown_browserproof only reads JSON with anaccountand an integerat, which a decrypted secret never is, so one can't stand in for the other. A purpose tag would need the PHP package too.r.FullURL()keeps the query string as sent (step 10a, review), where Laravel'sfullUrl()sorts it: a signed-out browser at a page that serves guests is sent back to/welcome?b=1&a=2in Go and/welcome?a=2&b=1in PHP. The same page either way;docs/rust/differences.mdnotes it for the Rust crate.The policy is a closure with the request's context (step 10b):
Require(func(ctx, *U, Attempt) Requirement), as PHP's closure of the user and the attempt; the context is there fordate.Now(Device.IsTrusted(ctx)). No fixed-requirement setting beside it (PHP'srequire(Requirement), the Rust crate'sKeyringConfig::policy): a closure returning one does the same.Requirements hang off
Level(step 10b):keyring.AAL2.Requirement(), sinceAAL1–AAL3were alreadyRequireAssurance's level constants;RequireFactors/RequireStepsfor PHP'sfactors()/steps();NoDowngrade()andNoDowngradeExcept(...)for PHP's default argument. The zeroRequirementis the default policy rather than a requirement of nothing.A pipeline step is an interface value, Keyring's own fixed in code (step 10b), as the Rust crate:
EnsureNotThrottled,VerifyFactorandCompleteAttemptcan't be taken out even dangerously, and the application's steps only go between the last two. PHP lets a step go anywhere and replace any step dangerously.The unregistered-factor refusal stays with
DetermineRequirement, in PHP's order (step 10b), so an application's step afterResolveDeviceruns first; with that step dangerously removed or replaced, Keyring still refuses such an account (stricter than PHP, where the refusal goes with the step).ResolveDevicedoesn't notetrust(step 10b): Go keeps "don't ask again on this device" where it was (the first factor's form, a challenge answer), so removing or replacing the step doesn't lose it, where PHP'sResolveDeviceis what notes it.keepOutsigns this browser out even when ending the others fails (step 10b), answering 500 with the error, where PHP throws before its own sign out.AllowSignInWhenanswers a bool (step 10b), as PHP's closure; the Rust crate'sAuthorizesSignIncan fail.AllowsSignIn(nil, user)is allowed outside a request, a followed verification link then counting for nothing.A minimal
Risktype now (step 10b):Risk{Findings []Finding{Signal, Score, Reason}}withHas, so the policy API and the contract app'sWarypolicy are final; step 11 fills it and may add the level and score.An
Actionis a struct of fields (step 11),keyring.Action{StepUp: true, Notify: true}, rather than the PHP package's builders, andLockFora duration (zero locks nothing, where PHP'slockFor(0)names the actionlocked).DefaultRiskResponsegives criticalDenyandReauthenticateboth, as PHP'sdeny(); an application'sAction{Deny: true}is answered the same everywhere.RespondToRisktakes the context (step 11),func(ctx, *Risk, Checkpoint) Action, asRequiredoes;RiskSignalsadds to the signals (PHP'spush()), since a Go application sets them up once in code; there's no replacingsignals().Signals aren't generic (step 11):
Assessment.Userisany(a*U), so the built-in signals are plain values (keyring.NewDevice{}), as the Rust crate'sdyn Anyuser. A built-in signal's zero field takes the PHP default, so a score of 0 can't be asked for (take the signal out instead).Risk.Levelsmust be ordered, with a medium of at least 1 (step 11), refused at Register: PHP takes anything, and levels left at zero (cfg.Risk = keyring.RiskSettings{Store: ...}) would make every assessment critical and refuse every sign in.Risk.Storenames a cache store as PHP'srisk.store; one that isn't configured panics at the first lock (Laravel Go'scache.Named), a 500, as Register can't look.A sign in's attempt always carries a risk once assessed (step 11), empty when no signal found anything (or none are set), as PHP's
AssessRisksets$attempt->riskevery time: a policy'sattempt.Riskis nil only outside a sign in (a confirm, a removal, a fresh verification). Step 10b's test that it was nil at sign in now asks for an empty one.Countries are compared as text (step 11), as the Rust crate: PHP's
contains()compares loosely, so"1"and"01"would be one country there. A location is an ordered list, kept in the locator's order as PHP's array keeps it; an empty one is unknown, where PHP would store[]for a locator that returned an empty array.ImpossibleTravel's distance can differ from PHP's in the last bit (step 11): Go'smath.Sin/Cosaren't the C library's. Only a distance a hair from a whole kilometre could print differently.The
new_deviceentry says "near" (step 11), as PHP'sdescription()does, now that devices have places: entries from step 3 on said the name alone because there was nowhere to be near.A failed stepped-up mark is ignored (step 11), as PHP's
rescue(report: false): requests stepping up alongside then stay on their record, and their next request finds it ended.A risk step-up's new record is used now (step 11, review), where the PHP package (
swapRecord()'s$session->with([...])) and the Rust crate copy the old record'slast_activity_at: a session stepped up near its idle limit otherwise idles out minutes later, since the request's use is noted on the record it moved on from. PHP and Rust should take this fix too.ID tokens are checked by a leaf package of our own on the standard library (step 12),
go/keyring/jose, PHP'sSignedTokenport, aswebauthnis webauthn-lib's: a library (go-jose, lestrrat's jwx) would takealgvalues, key shapes, JSON and base64 PHP refuses, or refuse some it takes, and a parity port has to accept and refuse what PHP does. Checked token by token against PHP. One gap: Go'scrypto/rsarefuses an RSA exponent over 2³¹−1, which OpenSSL takes; no provider publishes one.Where a provider's URLs point is a leaf package too (step 12),
go/keyring/hosts, PHP'sfilter_var(),parse_url()and the RFC 6890 tables ported line by line, with the Rust crate's two fixes kept, stricter than PHP:::ffff:0:0/96reaches its IPv4 address so it's inward, and a URL without a host or a known port is never the same host as anything.Factors.SingleSignOnstarts off (step 12), as the Rust crate'sfeatures.sso: it needs a provider. A link on an account with it off isunknown, as any factor Go doesn't have, and the account is refused at sign in with theunavailable422, as PHP refuses one with a factor it doesn't register.All four of the PHP package's drivers are ported (step 12), not only
oidc: Google and Microsoft are OpenID Connect with their own issuer rules, and GitHub is small; links any of them made in PHP sign in here.Providers are a slice, and a name given twice stops Register (step 12), where PHP's are an array's keys and can't repeat. Anything else wrong with one is found when it's built, reported and left off the login page, a 500 at its routes, as in PHP.
SSO.ResolveHostsis a setting (step 12), PHP'sHostResolver::fake()for tests: nil asks DNS.Linking refuses an account any row has already, confirmed or not (step 12), the Rust crate's
taken(), before inserting: PHP inserts and turns the unique violation away the same, so only the order differs.An application's driver's identity is held to the provider and request Keyring knows (step 12), the Rust crate's
vouched(), where PHP takes what its driver says.A callback's
amrgiven as an object is read in key order (step 12): Go's decoded maps don't keep PHP's insertion order. It's the provider's say, kept for the application, and counts toward nothing.Discovery documents are cached as their checked body and read again from the cache each time they're needed (step 12), where PHP keeps one per provider object for the request: the same answers, a few more cache reads.
The callback runs its middleware itself (step 12), as the PHP controller's
through():Guestand the login options' limit for a sign in,Authenticate,Config.ChangesMiddlewareand the forms' limit for a link,Authenticateand the forms' limit for a confirm. The impersonation refusal joins them in step 13.A gate that panics fails a start as a 500, and counts as a no while an impersonation runs (step 13a), as the PHP package throws the callback's exception at a start and rescues it in
ending(). The previous draft refused both asnot_allowed.Every pending contract test left run-go's list in step 13a, not only the two impersonation entries: enrollment's, own-sign-out's and guest-pages' impersonation tests, and pages' and risk's, which the email changes (42144a7) already passed, and
email-changesitself joined the list, which that commit had left off.The impersonator's password is checked by a keyed hash of their hash (step 13a), as the Rust crate, where PHP keeps the guard's
hashPasswordForCookie(): it's only kept in the session, which the two never share, so only the form differs.Primary-factor keys are known process-wide (
primaryRegistry, as the Rust crate'sCLASSIFIED), so two apps in one process can't use one key differently. Threading config through a dozen helpers was the other option.LinkNewAccountdispatches nothing, as PHP's documented sign-up inserts the row with no event (Rust dispatchesAuthenticatorAdded). The events table matches PHP's.GET /login/{factor}/optionsis one static, unnamed route per app factor: a generic one clashes with/login/challenge/{factor}inhttp.ServeMux. Only the passkey's keepskeyring.login.options.AttemptandAttemptSSOreturn(*web.Response, error), refusals as the error, as PHP throws and Rust returnsResult.Starter kit has no security keys (not ported) and no unverified-sign-in setting (Go's
Registrationhas onlyRevealTaken); it uses Laravel Go'sauth.Authenticateandauth.RequireVerifiedEmailin place of Rust's hand-writtenRequireUser;DB_TIME_PRECISION=0as the contract app.Email-change review fixes:
Config.GuardChangesManuallyis a code setting, not an env var, for users that aren't Laravel Go models. Without it, Register refuses a user type with nomodel.UpdatingHookwhile anything is protected; PHP's trait makes the protection automatic.db.Raw, or a missing row,GuardChangesrefuses.auth.WithUsercounts as the bypass actor.model.Updateis refused outside a flow whileUpdatePasswordsis on, as PHP would refuse its ownAuth::attemptrehash. Keyring for Go doesn't rehash.EndUnsavedSignInsfires only on a 5xx that carries no session cookie (store unwritable or panic). Laravel Go saves the session whatever the handler answers, so Rust's "any 5xx" signed out browsers already on their new record and broke four tests. PHP has nothing like it.Sessions.SweepEveryzero means off: Go can't tell zero from unset, where PHP warns on an explicit zero. Negative values are refused.keyring:installprintscfg.Factors.Passkeys = false/cfg.Features.SecurityLog = falsewhen not picked, since Go defaults them on and PHP leaves unpicked ones commented out.keyring:importreads the tableSessionUserTypenames,--tableto override (as Rust), since Go can't see the app's model as PHP's Eloquent provider does.Prune output names tables ("Pruned 1 [keyring_devices] records."), as Rust; PHP's
model:prunenames model classes.SSO review fixes:
parse_strin full: malformed escapes are kept as written, names cut at a NUL, spaces and dots before[become_.httpclienttestfakes answer them. Keyring's own transport rebuilds each request from only what Keyring wrote, with retries off, so nothing the app adds reaches the provider. The app'sBeforeSending/AfterResponsehooks and debug log still see the requests, client secret included.Freshness()is""with none configured can't be built. An unrecognised value counts as never.Laravel-Go/<version>.keyringtest.New[U](t, client)is one helpers object rather than package functions takingtandclient: laraveltest doesn't expose the test from a client, and Go can't add methods tolaraveltest.Client.Conformance builds a fresh app per check (PHP's one test per check on a fresh database) rather than Rust's one app and a report;
Checkstill returns anOutcome.Factory recovery codes aren't PHP's fixed
aaaa-…codes: matching would need Keyring's code hashing exported. Worth adding if apps want PHP's constants.Step 13b review fixes:
SignInAsrefuses a row of a factor the app has turned off (PHP'sUnknownFactor), with an unexportederrUnknownFactorthat answers 500.Registerrefuses a primary factor that shares its key with another Keyring's code factor. The same primary factor in two Keyrings is still allowed, because the tests build many apps in one process.keyringtest review fixes:
Registerresolves every host to nothing, as PHP'sHostResolver::fake(). A dotted host counts as outside the network and a single-label host as inside.AddToruns, and tohttp://localhostbefore that. PHP always asks the container.Impersonation review fixes:
SignInAsincluded, ends the impersonation first, assigned_out, together with the parked session. Rust refuses with a 403 instead.auth.Loginas someone else while impersonating ends the impersonation as PHP'sregister()does. So do its ownauth.Logoutand emptying the session.Impersonation.ShowInSessionsis now*bool(nil means on), asPasswords.Uncompromisedis, so assigning the whole struct no longer hides the session. Anyone who wrote= falsemust now write= new(false).ShowInActivity *boolis a slot nothing reads yet.auth.Logout, which would rotate their remember token. This is documented, not fixed.end_parkedhas the gap Go's now closes: it decides under the cache lock alone, where it needsholding_user_rowand a re-check after the end. Worth taking to Rust.Console-command review fixes:
SweepLimit), so a struct set whole can't wipe a table. Negative values are still refused.end_reasonannounces asrevoked, using PHP's list, includingaccount_deleted.RefreshDatabasedrops read hosts.EndUnsavedSignInsentry above: a panic is a 500 whose session still saves, so only an unwritable store leaves a record to end.Final review fixes:
keyring:installalways asks for the user model'sUpdatinghook when update-passwords or email-changes is on. PHP asks only when the model lacksHasKeyring, but Go can't see the app's model.pagefrom route names, as PHP'sStatusResponsedoes. WithConfig.Routesoff and no route namedlogin,pageis left out rather than claimed.PasswordChangeReasonandRequirePasswordChange's existence check still use the default connection; a missed hold there only hits the unique index.Base merge and the email code's sign-in link (PHP feat(email-code): add an opt-in sign-in link and make the code easier for mail apps to find #160):
feat/laravel-rust-support, which took Skip the test jobs on draft pull requests #157, docs: explain running a headless frontend behind a same-origin proxy #159 and feat(email-code): add an opt-in sign-in link and make the code easier for mail apps to find #160 from main). The Rust crate hasn't ported feat(email-code): add an opt-in sign-in link and make the code easier for mail apps to find #160; Go follows PHP.EmailCodes.Linkis on, so there's noRequireSignInLinkstype. PHP always registers both routes and has middleware answer 404. The browser gets the same 404; only a route list differs.VerificationCode.Grouped()is removed: its only job was PHP's groups-of-four line, which PHP dropped.deliverForis an optionalSendsCodesFor[U]interface on a code factor's sender, with a new publicCodeAttempt{ID, Purpose, ExpiresAt}:keyring.Attemptexists, but it carries risk and lazy device lookups a sender doesn't need.