Repository navigation
7.0.0-beta1
Pre-release
Pre-release
- PHP 8.4+ is now required.
- (ADD) Built-in OAuth 2.0 support. A new
Aura\Auth\Adapter\OAuth2Adapterruns the authorization-code exchange and maps the resource owner to[$username, $userdata]via a configurableusername_fieldormapcallback. Providers are reached through a smallAura\Auth\OAuth\ProviderInterfaceseam (with aLeagueProviderwrapper forleague/oauth2-client, kept as asuggest/require-devdependency so the core stays dependency-light). A newAura\Auth\OAuth\AuthorizationCodeFlowdrives the flow securely: it generates and persists the anti-CSRFstateand a PKCEcode_verifierwhen supported, andhandleCallback()handles provider errors, validatesstatein constant time (consuming it), and returns only the validatedcode/code_verifierto pass tologin()— never raw$_GET. Build withAuthFactory::newOAuth2Adapter()andAuthFactory::newOAuth2Flow(). Seedocs/oauth.md. - (ADD) "Remember me" support (issue #4). A new
Aura\Auth\Remember\RememberServiceissues, resumes, and forgets long-lived login tokens using the split-token (selector/validator) scheme with server-side storage and per-use token rotation. Storage is pluggable viaRememberStorageInterface, with a PDO-backedPdoRememberStorageprovided. A newStatus::REMEMBERED(andAuth::isRemembered()) marks users re-authenticated from a cookie as lower privilege than credentialed (VALID) users. TheLoginService,LogoutService, andResumeServiceaccept an optionalRememberServiceso the feature works through existing call sites; the added constructor parameters are nullable and backward compatible. Build the pieces withAuthFactory::newRememberService()andAuthFactory::newPdoRememberStorage(). See the README "Remember Me" section. - (ADD) LDAP "bind, search, rebind" support (issue #45).
Aura\Auth\Adapter\LdapAdapteraccepts an optionalsearchconfiguration (binddn,bindpw,basedn,filter, and optionalattributes); when given, it binds with a service account, searches for the user's real DN — which may live anywhere in the tree, so users spread across multiple OUs are now supported — then rebinds as that DN to verify the password, returning the discovered attributes. Withoutsearchit behaves exactly as before (direct bind viadnformat), so the change is backward compatible. A failed search operation raises the newAura\Auth\Exception\SearchFailed, kept distinct from a successful zero-result search (UsernameNotFound). Configure viaAuthFactory::newLdapAdapter(). A real-OpenLDAP integration test suite (opt-in viaLDAP_TEST_URI) runs in CI. Seedocs/adapters.md. - (FIX)
Aura\Auth\Verifier\PasswordVerifiernow works with Argon2. It decided betweenpassword_verify()andhash()by testingis_string($algo) && $algo !== PASSWORD_BCRYPT, which was correct when thePASSWORD_*constants were integers; PHP 7.4 turned them into strings ("2y","argon2i","argon2id"), so every algorithm except bcrypt fell through to thehash()branch. As a resultnew PasswordVerifier(PASSWORD_ARGON2I)orPASSWORD_ARGON2IDraisedValueError: hash(): Argument #1 ($algo) must be a valid hashing algorithmon every login attempt, making Argon2 unusable through this class. The check is now! in_array($algo, password_algos(), true), which keeps every algorithmpassword_hash()supports — including ones added in future PHP releases — on thepassword_verify()path. No working configuration changes behaviour, since the affected ones could not authenticate at all. - (CHG)
PasswordVerifierconfigured with ahash()algorithm now readspassword_hash()output as well, deciding from the stored value rather than from its own configuration. This is what makes migrating a legacy column safe: accounts move to the new algorithm one at a time as their owners log in, so the column holds both kinds of hash throughout, and a verifier that only understood its configured algorithm would reject every account the moment it was migrated — locking each user out on their next visit.needsRehash()correspondingly reports false for a value that has already been migrated, so a migrated row is not rewritten on every login. - (ADD) Password rehashing support. A new
Aura\Auth\Verifier\RehashInterface(implemented byPasswordVerifier) reports when a stored hash should be replaced, andPdoAdapter/HtpasswdAdapterexpose the result of the login that just succeeded vianeedsRehash()— the one moment the plaintext is available to produce a replacement.PasswordVerifiertakes an optional second constructor argument ofpassword_hash()options, so a raised bcrypt cost is detected as well as a changed algorithm; a legacyhash()digest always reports true, so migrating off one is self-driving.RehashInterfaceis deliberately separate fromVerifierInterface, andneedsRehash()is deliberately absent fromAdapterInterface, so existing implementations of both are unaffected;ThrottleAdapterforwards the report to the adapter it wraps. See "Rehashing Stored Passwords" indocs/adapters.md. - (ADD) Automatic password rehashing. Passing an implementation of the new
Aura\Auth\Rehash\RehashStorageInterfaceto an adapter'ssetRehashStorage()makes it replace an outdated hash during a successful login, instead of reporting the condition throughneedsRehash()and leaving the application to act on it — which silently migrates nothing if the check is forgotten or missed on one login path. A PDO-backedAura\Auth\Rehash\PdoRehashStoragecovers a single accounts table (build it withAuthFactory::newPdoRehashStorage()); anything more involved implements the one-method interface. The target algorithm belongs to the writer rather than the verifier, which is what allows a legacy column to migrate: the verifier reads MD5 while the writer stores bcrypt. A failed rehash never fails the login — it is housekeeping, so the exception is captured and exposed throughgetRehashError()for logging rather than propagated, andneedsRehash()stays true so a manual block still sees the outstanding work. See "Rehashing Automatically" indocs/adapters.md. - (FIX) Close a username-enumeration timing leak in
PdoAdapterandHtpasswdAdapter. Both threwUsernameNotFoundbefore any password verification ran, so an unknown username returned in about a millisecond while a known one paid a full bcrypt verification — a difference readable straight through internet jitter, letting an attacker harvest valid usernames with a junk password and a stopwatch. Both adapters now run a throwaway verification against a dummy hash on the not-found path before throwing the same exception as before, measured at 1.00x where it had been 3.98x. The dummy hashes are public constants onAbstractAdapterand matched to PHP's default bcrypt cost (which changed from 10 to 12 in PHP 8.4);getDummyHash()can be overridden by deployments that set cost explicitly. The protection does not depend on the constants being secret — it removes the timing signal rather than hiding it. Seedocs/security.md. - (ADD) Format-matched dummy hashes, via a new
Aura\Auth\Verifier\DummyHashInterface. The enumeration fix above verifies against a bcrypt dummy fromAbstractAdapter, which equalises the two login paths only when the stored hashes are bcrypt too. In front of a legacyhash()column or an htpasswd file of$apr1$/{SHA}entries — all verified in microseconds — it did not close the gap but inverted and widened it, taking the unknown-username path from 0.0002ms to 261ms against a 0.0002ms wrong-password path: a cleaner signal for an attacker than the original bug, pointing the other way. Only the verifier knows which format it reads, so the verifier now supplies the dummy.PasswordVerifierbuilds one from its configured algorithm and options, so pinningarray('cost' => 13)pins the dummy too;HtpasswdVerifierbuilds one from a format named in its new optional constructor argument (apr1by default, what plainhtpasswdwrites), plus an optional second argument ofpassword_hash()options for thebcryptcase —$2y$encodes its cost, andhtpasswd -Bwrites cost 5 by default where PHP writes 10 or 12, soarray('cost' => 5)is what keeps that file's two paths level. Those arguments affect nothing but the dummy —verify()still dispatches per entry, so mixed-format files still authenticate everyone. Each dummy is generated fromrandom_bytes()and memoised, so nothing verifies against it and the failure path pays for one verification rather than two.DummyHashInterfaceis optional and checked withinstanceof, so third-party verifiers keep the previous behaviour andAbstractAdapter::getDummyHash()remains as their fallback. Each configured format now measures at a ratio of about 1; a file mixing formats can only be matched to the one the bulk of it holds, so a residue remains there. Seedocs/security.md. - (DOC) Document the enumeration timing gap the library does not close, in
docs/security.md. The page described the throwaway verification inPdoAdapterandHtpasswdAdapterwithout mentioning the network adapters at all, which invited the assumption that every adapter was covered.LdapAdapterin bind-search-rebind mode still answers an unknown username a round trip faster than a wrong password, because a search matching nothing throws before the rebind ever happens; its direct-bind mode has no such gap, andImapAdapterdraws no distinction of its own. The note explains why a throwaway bind is not the fix — it would send the submitted password to the directory under a nonexistent DN and write a failed-bind record to its audit log on every unknown username, which is what intruder detection and lockout policy are usually driven by — and points at direct bind and at throttling instead. - (FIX)
NativeRedisClientno longer reports a failed Redis read as a failure count of zero.hashGetAll()folded any non-array reply into an empty array, whichRedisThrottleStorage::getFailures()reads as "no failures recorded" — so a key that could not be read silently switched throttling off for that account, and stayed off, because the matchinghincrby/hsetwrites were dropped just as quietly. Commands whose failure is reported by return value rather than by exception now raiseException\ConnectionFailed, which fails closed:ThrottleService::assert()runs before the wrapped adapter, so a broken backend blocks attempts instead of waving them through, matchingPdoThrottleStorage, which already lets PDO's exceptions propagate. This is narrower than it sounds — phpredis throws of its own accord when the connection is refused or drops, so an unreachable Redis already failed closed; what is covered is chieflyWRONGTYPE, when another application shares the database and puts a non-hash under the throttle prefix. The guard tests for an exactfalse:HSETandDELanswer0on ordinary outcomes andEXPIREanswersfalsefor a key that no longer exists, so a looser check would throw on healthy traffic;expire()anddelete()stay unchecked for that reason, and a droppeddelete()errs safe anyway by leaving the counter in place. - (FIX)
HtpasswdVerifier's APR1/MD5 computation is now reachable ascomputeApr1(), split out ofapr1()so a dummy in that format can be generated. PHP'scrypt()has no$apr1$support — it answers*0— so the package's own implementation is the only source of a valid one; a*0would have fallen throughverify()to the DES branch and cost the wrong amount while still looking plausible. Verification behaviour is unchanged, and is now checked against realhtpasswd -moutput. - (FIX) Compare hashes with
hash_equals()rather than===inPasswordVerifier(thehash()algorithm path) and inHtpasswdVerifier's SHA, APR1/MD5, and DES paths, so comparison time no longer depends on how many leading characters matched. The original code predateshash_equals(), which arrived in PHP 5.6 — after this code was written against aphp >=5.4.0requirement. - (ADD) Depend on the new
aura/session-interface(^7.0) package, which provides the shared session/segment contracts. - (CHG)
AuthFactory,Auth, and theLoginService/LogoutService/ResumeServicenow type-hint the sharedAura\Session_Interface\SessionInterfaceandSegmentInterface. As a result anAura\Session\Sessionand its segments — or any other implementation of the shared contracts — can now be passed to Aura.Auth directly, while the built-in lightSession/Segmentcontinue to work standalone. - (CHG)
Aura\Auth\Session\SessionInterfaceandAura\Auth\Session\SegmentInterfaceare deprecated. They now simply extend the shared interfaces and are retained only for backward compatibility; type-hint theAura\Session_Interfaceversions instead. - (CHG) Add native
string/mixed/bool/voidtype declarations toSession,Segment,NullSession, andNullSegmentto match the shared interfaces. - (CHG) Use explicit nullable types (
?Type) for parameters that default tonullinAuthFactoryandImapAdapter, fixing the PHP 8.4 implicit-nullable deprecation. - (TST) Update test doubles and test classes for PHP 8.2 (declared properties instead of dynamic ones).
- (TST) Require
phpunit/phpunit^11.0and modernize the suite for it: mock proxiedPhpfuncfunctions via real test doubles withonlyMethods()(replacing the removedaddMethods()), usewillReturn()instead ofwill($this->returnValue()), and migrate doc-comment metadata (@runInSeparateProcess,@runTestsInSeparateProcesses,@preserveGlobalState) to PHP attributes. The CI matrix now targets PHP 8.4/8.5. - (CHG) Remove Psalm: drop the
vimeo/psalmdev dependency, thepsalm.xmlconfig, and the Psalm CI job. - (CHG) Document that passing a
hash()algorithm name toPasswordVerifier(new PasswordVerifier('md5')) compares an unsalted digest with no work factor, and exists only so a site with a legacy password column can authenticate users while migrating them.docs/adapters.mdgained the warning and a migration recipe, and a stale reference toHashVerifierwas corrected — that class was merged intoPasswordVerifierin 2014. A newdocs/security.mdcollects the account-enumeration and password-storage notes, including the part the application owns: adapters throw distinctUsernameNotFoundandPasswordIncorrectexceptions for logging, and rendering them as different messages hands an attacker what the timing fix protects. - (ADD) A
docs/schemas.mdreference withCREATE TABLEstatements for SQLite, MySQL/MariaDB, and PostgreSQL covering theaura_auth_remember,aura_auth_token, andaura_auth_throttletables, plus an exampleaccountstable. The page publishes the same.sqlfiles the new PDO integration job executes, so the documented schema is one that is tested rather than one written from memory; a test fails if the two drift apart. Previously the only per-engine guidance was a parenthetical in a class docblock. - (TST) Real MySQL and PostgreSQL integration tests. A new opt-in suite (
--group pdo, skipped unlessPDO_TEST_DSNis set) exercisesPdoAdapterand the PDO-backed remember-me, token, throttle, and rehash storages against real servers, run in CI against MySQL 8.0 and PostgreSQL 16 via service containers. SQLite hides portability problems — it has dynamic typing, no strict mode, and its own string-comparison rules — so anything depending on the server was previously untested. One case is called out explicitly: MySQL's default collation is case-insensitive and itsVARCHARcomparison ignores trailing spaces, soALICEandaliceboth match a storedalicethere while PostgreSQL matches neither; the adapter must return the stored username either way, or session identity varies by how the user typed their name and anything keyed on it splits in two. - (TST)
PdoAdapterTestfixtures now use bcrypt (at cost 4, bcrypt's minimum, to keep the suite fast) instead of MD5, so the most-read usage example no longer models a configuration the docs warn against; dedicated tests keep the legacyhash()path covered.