Repository navigation
Releases
Releases · hmmdlthf/golaravel
GoLaravel v1.17.2 - TOTP clock-drift tolerance default
Fixed
- TOTP clock-drift tolerance was off by default:
NewTOTPManager(TOTPOptions{...})withSkewWindowleft out (asWorkflowControllerand gofilament do) accepted only the current 30-second code.SkewWindow: 0now keeps the default of one step either side; use the newauth.NoSkewto accept only the current step.
GoLaravel v1.17.1 - StartSession default manager, constant-time session CSRF
Fixed
session.StartSession(mgr)built the default manager: apps passing their own manager still built the unused default and logged its "no SecretKey" warning. The default is now resolved on the first request, only when no manager is given.- Session CSRF check timing (
session.VerifyCSRFToken): tokens are compared in constant time, and an empty session token is refused.
GoLaravel v1.17.0 - session login, user-linked sessions, SQL reset tokens
Added
- Session login (
pkg/auth):auth.Login,auth.Logout,auth.LogoutOtherDevices,auth.SessionGuard/SessionGuardFuncandauth.UserProviderFunc, so server-rendered sites can log in with the session cookie instead of a JWT. Login regenerates the session id and deletes the old one, and renews the CSRF token. Logout destroys the session and issues a new CSRF token. - Sessions linked to users (
pkg/session): the SQL driver has a nullable, indexeduser_idcolumn (Migrateadds it to existing tables).Manager.DestroyUserSessions(userID, except...)ends a user's sessions on the memory, file, SQL and Redis drivers. The cookie driver returnsErrUserSessionsUnsupported. NewManager.Regenerate,Manager.Invalidate,session.ManagerFrom(c)and theUserSessionDriverinterface. auth.SQLResetTokenStore: password reset tokens in apassword_reset_tokenstable (SQLite, includingmodernc.org/sqlite, MySQL and Postgres), withMigrateandPruneExpired.
Changed
- No warnings at import: the default session manager and disk manager are built on first use instead of at package load. The default session manager takes its key from
APP_KEY. The "no SecretKey" warning is logged only when a manager is built without a key, and the storage "no signing secret" warning only when a URL is first signed with the random key.
GoLaravel v1.16.0 - 128-bit support ticket IDs
Security
- Support ticket IDs (
pkg/support):GenerateTicketIDproduced only 32 bits of randomness (TKT-plus 8 hex characters), which can be brute-forced. For visitors who aren't signed in, the ticket ID is their only access to the ticket, so IDs now carry 128 bits (TKT-plus 32 hex characters).
Full changelog: v1.15.0...v1.16.0
GoLaravel v1.15.0 - 2FA bypass fix and auth hardening
Security
- 2FA bypass (
pkg/auth): thetwo_factor_tokenreturned after a correct password (before the second factor) was signed with the same secret as access tokens, soBearerGuard/CookieGuardaccepted it as a full login. Two-factor authentication could be skipped entirely. Challenge tokens now use a derived key and their own audience, and the guards refuse them. - Auth workflows (
WorkflowController):- Throttling: logins and 2FA codes are throttled through the
ratelimitstore (LoginAttempts/LoginWindow,TwoFactorAttempts/TwoFactorWindow). A 6-digit code can no longer be brute-forced. - Account enumeration: unknown emails take as long to reject as wrong passwords.
- Codes: TOTP codes are single-use (
TOTPManager.VerifyCodeStep). Recovery codes are refused whenUpdateRecoveryCodesis not configured (they would never be used up), and no token is issued without a verified factor. - Password resets: only existing accounts get reset mail, the reply is the same either way, mails are throttled per address, and the reset link is URL-encoded.
- Disabling 2FA requires the current password or a 2FA code.
- Errors: callback errors are no longer sent to the client. Passwords over 72 bytes (the bcrypt limit) get a validation error instead of a 500.
- Throttling: logins and 2FA codes are throttled through the
- OAuth: the
stateand PKCE cookies areSecureon HTTPS.
Fixed
- Panics in scheduled tasks (including
RunInBackground), async event listeners and queue jobs crashed the process. They are now recovered: tasks report an error, and jobs are retried or sent to the dead-letter queue. schedule:Execkeeps only the last 64 KiB of command output.OnOneServerlogs a warning when the default cache is the in-memory store, since it then only prevents duplicates within one process.
Breaking
POST /auth/two-factor/disableneedspasswordorcodein the body.- Recovery codes are refused unless
WorkflowCallbacks.UpdateRecoveryCodesis set. - Forgot-password sends no mail when
FindByEmailfinds no user (the response is unchanged). - Existing 2FA challenge tokens stop working (they expire within 5 minutes anyway).
Full changelog: v1.14.0...v1.15.0
GoLaravel v1.14.0 - Security pass
Security
- Broadcast channels (
pkg/broadcast):- Anyone could listen on any channel. The SSE handler took
?channel=, and the WebSocket handler subscribed to whatever channel the client named.broadcast.Channel("orders.{id}", fn)now registers authorization callbacks, like Laravel's channel routes.private-andpresence-channels without a rule are refused, and other channels stay public.Options.Authorizecan decide every subscription instead. - Cross-site WebSocket hijacking. WebSockets accepted every
Origin, so any site could open one with the user's cookies. Now only the same origin, clients that send noOrigin, andOptions.AllowedOriginsare accepted. - Smaller fixes: the SSE
connectedevent escapes the channel name (it was written raw, allowing JSON and SSE frame injection), event names are stripped of newlines, channel names with control characters are refused, and a WebSocket may hold at mostMaxSubscriptions(100) channels. - New:
SSEHandlerWith/WebSocketHandlerWith(Options).
- Anyone could listen on any channel. The SSE handler took
- Signed storage URLs (
pkg/storage):NewLocalDriversigned temporary download and upload URLs with a hard-coded fallback key whenAPP_KEY/STORAGE_SECRETwas unset, so anyone could forge them. It now uses a random per-process key (with a warning), and refuses the old public key. - Tenancy (
pkg/privacy):TenantMiddlewaretrusted whatever tenant the client named (X-Tenant-ID, query, route parameter or subdomain). NewTenantMiddlewareOptions.Authorizechecks membership and answers 403 when it fails. Without it, a one-time warning is logged. - SMTP (
pkg/mail):Encryption: "starttls"silently fell back to plain text when the server didn't offer STARTTLS (an attacker can strip the offer); it is now required. Connections and the SMTP conversation have timeouts (SMTPConfig.Timeout, default 30s). - HTTP client (
pkg/http): response bodies are capped at 64 MiB (MaxResponseSize,ErrResponseTooLarge) instead of being read fully into memory. - Metrics (
pkg/telemetry):- Path labels are capped (
MaxPaths, default 500; the rest count asother), so random URLs can't grow the metrics without bound. NormalizePathsnow works: ID-like segments become:id.traceparentIDs must be lowercase hex and non-zero.
- Path labels are capped (
- Flutter (
pkg/flutter):VersionandBuildIDare escaped in the injected HTML.
Breaking
- Cross-origin WebSockets: browser WebSockets from another origin, such as a Flutter web build on a different host, need
broadcast.WebSocketHandlerWith(broadcast.Options{AllowedOrigins: [...]}). - Private channels: subscriptions to
private-/presence-channels need a matchingbroadcast.Channelrule. - Signed storage URLs: they stop working across restarts until
APP_KEYorSTORAGE_SECRETis set. - SMTP:
Encryption: "starttls"fails against servers that don't offer STARTTLS.
Full changelog: v1.13.0...v1.14.0
GoLaravel v1.13.0 - Method spoofing and .env fixes
Fixed
- Form method spoofing didn't work.
view.Method("PUT")emitted a_methodfield, but nothing read it, so HTML forms could never reach PUT, PATCH or DELETE routes. The engine now routes a POST with_method(or anX-HTTP-Method-Overrideheader) of PUT, PATCH or DELETE as that method, before routing. GET is never overridden. Turn it off withEngine.MethodOverride(false). .envparsing (pkg/config):export KEY=valuelines are read.- Unquoted values drop a trailing
# comment. - Double-quoted values support
\n,\"and\\, and their closing quote skips escaped quotes. Single-quoted values are taken literally. - Read errors are reported instead of being ignored.
Added
- Tests for
pkg/configandpkg/view, which had none.
Full changelog: v1.12.0...v1.13.0
GoLaravel v1.12.0 - Timeouts, cache stampede protection, validation rules
Added
- Request body read timeout:
Engine.BodyReadTimeout(default 2 minutes) andmiddleware.BodyReadTimeout(d)per route. Upgrade requests and requests without a body are not affected, and the deadline is cleared once the body has been read, so slow handlers and SSE streams keep working. - Cache stampede protection:
Rememberruns the function once for concurrent misses (per process, and across instances on the SQL / Redis stores through a backend lock;RememberLockTimeout). - Atomic
Pullon the SQL and Redis stores (Puller; RedisGETDEL). - Validation:
validation.Password()(min / max / letters / mixed case / numbers / symbols / not-in list, one message per unmet requirement;MultiRule),exclude,exclude_if,exclude_unless,exclude_with,exclude_without,required_array_keys, anddimensions(PNG, JPEG, GIF).
Changed
artisan make:oauthnow generates a working controller: aFindOrCreatehook, with a warning against linking accounts by email alone, issues the app's JWT instead of returning the provider profile and its access token. A test checks the generated code compiles.
Fixed
- Routes with more than 127 handlers overflowed the
int8chain index.
Full changelog: v1.11.0...v1.12.0
GoLaravel v1.11.0 - Asymmetric JWTs and one rate limiter
Added
- JWT with public/private keys (
pkg/auth):NewJWTManagerWithKey(privateKey, kid, ttl)signs RS256 (RSA ≥ 2048), ES256 (P-256) or EdDSA (Ed25519) tokens, so other services verify them with only the public key.- Verifying elsewhere:
NewJWTVerifier(publicKey, kid)andNewJWTVerifierFromJWKS(json)create verify-only managers, andJWKS()publishes the public keys. - Rotation:
AcceptKey(publicKey, kid)keeps accepting old keys; tokens carrykidand are checked only against that key. - Key files:
ParsePrivateKeyPEMandParsePublicKeyPEMread PEM keys. - Algorithm checks: the algorithm always comes from the manager, never from the token. Key-based managers refuse HS256 (no confusion with a public key used as an HMAC secret), and secret managers refuse key-signed tokens.
- Interoperability: the ES256 format is checked against the example in RFC 7515, appendix A.3.
- Verifying elsewhere:
Fixed
ratelimit.ThrottleMaxroutes shared one counter. The counter was keyed only by client IP, so traffic on a route with a loose limit used up a strict one elsewhere (for example a feed route locking users out of login). The limit is now part of the key.
Deprecated
middleware.RateLimiternow delegates toratelimit.ThrottleMax(n, time.Minute)instead of keeping its own in-memory token buckets. It therefore uses the configuredratelimitstore (shared between instances with the Redis store) and sends the standardX-RateLimit-*headers. Useratelimit.ThrottleMaxorratelimit.Throttledirectly.
Full changelog: v1.10.0...v1.11.0
GoLaravel v1.10.0 - CI, Redis consolidation and store fixes
Added
- CI (
.github/workflows/ci.yml): every pull request and push to master runsgo vetandgo test -race ./..., plus an integration job against real MySQL 8.4, Postgres 17 and Redis 7. - Integration tests (
integration/, a separate module) run on whichever backends are configured (GOLARAVEL_TEST_MYSQL_DSN,GOLARAVEL_TEST_POSTGRES_DSN,GOLARAVEL_TEST_REDIS_ADDR); SQLite always runs. They cover:- the SQL and Redis session drivers;
- the SQL and Redis cache stores, including concurrent increments, tags and locks shared between two instances;
- validation
unique/exists; - the Redis client;
- the queue and rate limiter Redis code.
Changed
- One Redis client.
pkg/queueandpkg/ratelimitnow use the sharedpkg/redisclient instead of their own copies. The queue's copy put a connection back into the pool after a network error, so later commands could read a half-finished reply. Blocking pops use the newClient.DoTimeout.redis.Opencreates a client without contacting the server. ratelimit.RedisStore.ClearusesSCANinstead ofKEYS, so it doesn't block a large Redis. NewRedisStore.Close.
Fixed
- Redis rate limiter could be exceeded.
Hitcounted and then added in separate commands, so concurrent requests (for example a burst of login attempts across instances) could all pass the limit. The trim, count and add now run in one Lua script; 50 concurrent hits with a limit of 10 admit exactly 10. - Delayed jobs on custom queues never ran. The Redis queue only moved due jobs for
default,highandlow; now it moves them for every queueLaterwas called with. Only the worker whoseZREMremoved a job pushes it, so two workers can't run the same delayed job twice. - Container singletons (
pkg/container): double-checked locking readinstancewithout synchronization (a data race the new-raceCI run found), and a singleton whose value was nil was rebuilt on every resolve. An atomic ready flag fixes both. - SQL cache
Incrementon Postgres (found by the new integration run): two concurrent first increments of a new key could both read 0, losing an update, becauseSELECT ... FOR UPDATElocks nothing when the row is missing. The row is now inserted before it is locked, and increments retry on deadlocks and serialization failures. - SQL cache locks on MySQL: re-acquiring a lock without expiry by its own owner returned false, because MySQL counts an UPDATE that changes nothing as 0 affected rows. The owner is now checked directly.
Full changelog: v1.9.0...v1.10.0