Skip to content

History of commits

4473 commits

feat(auth): store sign-in sessions on the server

Adds the auth_sessions table and the layer around it: one row per signed-in device, holding the digest of the cookie that device carries. This is what the previous scheme could not do at all. The cookie used to be md5 of the password, so it was valid until the password changed and there was nothing to revoke: no signing out elsewhere, no list of active devices, no dropping every session when a password changes. A row per device gives all three, and the cookie itself becomes 32 random bytes that mean nothing without the row. Lifetimes slide from the last visit rather than from the sign-in, so coming back on day 14 pushes the end to day 44 and only a real month of absence signs anyone out. Extending is a write, so it happens at most once every five minutes — measured against last_used_at on the row and not against anything this process remembers, or a visitor returning after a fortnight would never be extended. The absolute cap is off by default: switching it on would sign the most active visitors out every few months, which is exactly what the sliding window is meant to avoid. Rotation replaces the secret while the device keeps its row, so a value known before signing in or before a password change stops working afterwards. AuthCookieFactory is the only place a sign-in cookie is built, which is how its flags stop being forgettable: HttpOnly and SameSite=Lax always, Secure following the scheme of the request. Without "remember me" the cookie is a session one, but the row expiry is what actually limits the visit — browsers restore session cookies when reopening tabs. The manager stays free of HTTP so the lifetime arithmetic is testable without a request; nothing is wired into the request cycle yet.
simba77 14 aug. 2026 21:56 Branch: 10.x 87b788d

fix(auth): make password recovery links unguessable and single-use

The recovery code was md5(random_int(1000, 9999)) — nine thousand possible values, stored in the clear in users.rest_code. Anyone who knew an account id could walk the whole space in seconds and take the account over, and a database dump handed out working links directly. Recovery links are now 32 random bytes, kept only as a SHA-256 digest in the new password_reset_tokens table. The identifier still in the URL is a convenience: the token decides whose account it is, and a mismatch is rejected. Checking the link and spending it are separate steps, because the flow has two: opening the form only asks whether the link is still good, submitting it is what consumes the token. So an opened-but-abandoned link keeps working while a submitted one is dead, and a resubmitted form is a no-op instead of a second password reset. Asking for a new link drops the outstanding one, so only the newest letter works instead of every letter staying valid for its hour. The one-per-day limit now counts letters sent rather than links followed: spending a token no longer opens the door to asking for another one straight away. The table definition lives in AuthSchema, which the installer, the new auth:upgrade-schema command and the tests all call — a copy in any of them would drift and the drift would only show on somebody else's site. users.rest_code and users.rest_time are left in place for now; they are dropped with the rest of the legacy columns. Recovery links already in flight stop working when this is deployed.
simba77 14 aug. 2026 21:48 Branch: 10.x 03bba35

feat(auth): add the authentication and authorization skeleton

Introduces Johncms\Auth: the layer the new sign-in and permission system is built on. Nothing calls it yet, so behaviour is unchanged. Authentication is a chain: every AuthenticatorInterface tagged johncms.auth.authenticator is asked in turn and the first one to recognise the request wins; a request nobody recognises belongs to a guest. CurrentUser resolves that once per request, lazily, and is reset between requests. Authorization is a chain of voters: any Deny refuses, a single Allow is enough, and a check nobody voted on is refused. The asymmetry is what later lets a ban, an impersonation limit or the abilities of an API token take away what a role grants. Refusing by default means a permission whose voter was forgotten closes the door instead of opening it. Identity carries ids, role slugs and permission keys and nothing that needs a query, so authorization is testable without a container or a schema — tests/Support/IdentityFactory is what that buys. The can() helper and its Twig function are not here: with no voters registered they would answer false to everything, and a silent denial is the worst kind of placeholder. They arrive with the role voter.
simba77 14 aug. 2026 21:41 Branch: 10.x e073391

chore(mail): drop the unused smtp name option

A leftover of laminas-mail, where it was the HELO hostname. MailFactory builds the DSN from host, port, username, password, encryption and auth_mode and never reads this key, so it only misled whoever configured SMTP.
simba77 10 aug. 2026 22:41 Branch: 10.x ba01e5e

refactor: remove laminas-validator

The legacy validator, its rules and its message map are gone, and with the package go laminas-servicemanager, laminas-stdlib and laminas-escaper. No laminas package is left in the dependency tree. Not one msgid was lost: the strings the rules need are registered by literal d__() calls in their constructors and factories, so twenty catalogs survive the migration untouched. What the .pot loses is the detailed laminas hostname diagnostics and the CSRF message, none of which the code produces any more. .agents/validation.md documents the API, the null policy, how to add a rule and where its messages live.
simba77 10 aug. 2026 22:21 Branch: 10.x c0b4967

refactor(install): move the installer to the new validator

The last caller of the legacy validator and the last reference to Laminas\Validator\Hostname. The email stays mandatory: it was only rejected as empty because the previous EmailAddress failed on an empty value, and the new rule requires a value outright.
simba77 10 aug. 2026 22:17 Branch: 10.x cad631e