๐ Migration Guide๏
This document summarises breaking changes between major versions and how to upgrade. For the full per-release changelog, see CHANGELOG.md.
๐ Index๏
Upgrading to the next release (Unreleased)๏
The Unreleased section in CHANGELOG.md adds 13 features and a handful of internal improvements. No breaking changes โ all new behaviour is opt-in.
Required steps๏
Run migrations โ six new migrations ship with this release:
Migration
Adds
2026-05-07-000001_add_identities_user_type_revoked_indexComposite index on
auth_identities(user_id, type, revoked_at)2026-05-07-000002_create_audit_logs_tableauth_audit_logs2026-05-07-000003_create_totp_backup_codes_tableauth_totp_backup_codes2026-05-07-000004_add_trusted_until_to_device_sessionsauth_device_sessions.trusted_until2026-05-07-000005_create_password_history_tableauth_password_history2026-05-07-000006_add_password_changed_at_to_usersusers.password_changed_atphp spark migrate --all
Rename test helpers (deprecated, BC kept) โ if your tests use the typoโd helpers, the corrected names are now available; the old ones still work as deprecated aliases.
Before (deprecated)
After
$this->inkectMockAttributes(...)$this->injectMockAttributes(...)$this->inkectMockAttributesSecurity(...)$this->injectMockAttributesSecurity(...)$this->inkectMockAttributesOAuth(...)$this->injectMockAttributesOAuth(...)The deprecated names will be removed in v6.
Optional โ opt-in to new features๏
Each of these defaults to โoff / unchangedโ โ adopt only what fits your security posture.
Feature |
Where to enable |
Reference |
|---|---|---|
Throttle access-token |
|
|
Concurrent session limit |
|
|
Trusted devices (2FA bypass) |
|
|
TOTP backup codes |
(automatic on TOTP confirmation) |
|
Compromised-password recheck on login |
|
|
Suspicious login alerts |
|
|
Password history (no reuse) |
|
|
Password rotation policy |
|
|
API token scope enforcement |
Apply |
|
Login activity feed |
Wire |
What runs automatically (no action needed)๏
The audit log starts capturing events immediately for: TOTP enable/disable, password changes, lockouts, group/permission grants & revokes, token revocations, JWT logout. Use
auth:auditto read.OauthManager::handleCallback()now compares the OAuthstatewithhash_equals()(timing-safe) โ drop-in replacement.UserLockoutManager::recordFailedAttempt()now incrementsfailed_login_countatomically โ drop-in replacement.DeviceSessionRecorderno longer propagates DB errors โ they are logged and swallowed so a misconfigured tracking table canโt break login.
Upgrading to v5.x๏
What changed๏
OauthManagernow delegates all identity CRUD to a newOAuthTokenRepository.ProfileResolverFactory::create()accepts an optionalarray $providerConfigsecond argument.New OAuth events fire from
OauthManager::handleCallback():oauth-loginโ(User $user, string $providerName)oauth-profile-fetchedโ(User $user, string $providerName, array $profileData)
extraJSON on OAuth identities now storesscopes_grantedandprofile_fetched_atalongside the existingrefresh_tokenandprofile.
What you must do๏
If your codeโฆ |
Do this |
|---|---|
Calls |
Inject |
Listens for OAuth login via |
Switch to the new |
Uses |
Use |
Relied on the legacy plain-string format in the |
No action required โ |
No database migrations are required for the v4 โ v5 transition. Existing extra columns continue to work unchanged.
Upgrading to v4.x โ Config\Auth split๏
What changed๏
Config\Auth was split into three classes to keep concerns separate. Properties moved according to this table:
Property |
Old class |
New class |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Constructor signatures changed:
PasswordsandBaseValidatoracceptAuthSecurityinstead ofAuth. Custom password validators extendingBaseValidatormust update their type hints.OauthManageracceptsAuthOAuthinstead ofAuth.
What you must do๏
Step 1. Create the two new config files in app/Config/:
// app/Config/AuthSecurity.php
namespace Config;
use Daycry\Auth\Config\AuthSecurity as AuthSecurityConfig;
class AuthSecurity extends AuthSecurityConfig
{
// Move every customised security/lockout/password property here.
public int $minimumPasswordLength = 10;
public int $userMaxAttempts = 5;
// ...
}
// app/Config/AuthOAuth.php
namespace Config;
use Daycry\Auth\Config\AuthOAuth as AuthOAuthConfig;
class AuthOAuth extends AuthOAuthConfig
{
public array $providers = [
// Move your existing $providers array verbatim from app/Config/Auth.php.
];
}
Step 2. Remove the moved properties from app/Config/Auth.php. Anything not in the table above stays in Auth.
Step 3. Search-and-replace setting('Auth.X') โ setting('AuthSecurity.X') (or setting('AuthOAuth.X')) for every property listed above. Common offenders:
Before |
After |
|---|---|
|
|
|
|
|
|
|
|
|
|
Step 4. Update custom password validators:
use Daycry\Auth\Authentication\Passwords\BaseValidator;
use Daycry\Auth\Config\AuthSecurity;
class MyValidator extends BaseValidator
{
public function __construct(AuthSecurity $config)
{
parent::__construct($config);
}
}
Step 5. Run the test suite โ the type system will catch most missed renames.
General upgrade checklist๏
After any major version bump:
composer update daycry/authphp spark migrate --allโ applies any new migrations.composer testโ runs PHPUnit + code-style.Review your
app/Config/Auth.php,app/Config/AuthSecurity.php,app/Config/AuthOAuth.phpagainst the published versions for any new options worth adopting (e.g.permissionCacheEnabled,tokenLastUsedThrottle).Check
CHANGELOG.mdfor any non-breaking deprecations to plan ahead of v6.