Repository navigation
Upgrade if you use single_use: true or Doctrine DBAL 4.6. This release closes a concurrency race on single-use refresh token rotation, migrates all Doctrine date mappings to immutable types (datetime_immutable and date_immutable), and adds six opt-in operational and developer-experience features.
Security & Concurrency: refusing concurrent single_use refreshes
With single_use: true, two refresh requests presenting the same token at the same time could both be given a new pair, which is the stolen-token case rotation exists to end. The success listener ignored what delete() reported, and with hash_tokens it looked the token up a second time, so a request whose token had just been spent by the other was handed a replacement in a chain of its own, out of reach of reuse detection and max_session_lifetime.
The token is now spent only when the storage reports deleting its row; the losing request is refused with TokenNotFoundException like a replayed token, with nothing issued. PostRefreshTokenAuthenticationToken::getPresentedRefreshToken() carries the presented value for the request (not serialized), and Doctrine\RefreshTokenManager::delete() now asks the database what it deleted when the repository does not implement DeleteRefreshTokenRepositoryInterface.
Contributed by Karel Sommer (@calvera) in #437.
Doctrine DBAL 4.6 compatibility (datetime_immutable and date_immutable)
Doctrine DBAL 4.6 deprecated mutable datetime types in favour of datetime_immutable.
config/doctrine/RefreshToken.orm.xmlnow mapsvalidandfamilyValidasdatetime_immutable.config/doctrine/RefreshToken.mongodb.xmlnow mapsvalidandfamilyValidasdate_immutable.Doctrine\DBAL\TableSchemaManagerandDoctrine\DBAL\RefreshTokenManagerdefaultvalidandfamilyValidtoTypes::DATETIME_IMMUTABLEwhile respecting customdbal_columnsoverrides and normalizing anyDateTimeInterfaceinput to match the configured type.- Models, repositories, listeners, commands, and cache hydration now build
DateTimeImmutableinstances.
No database migration is needed on DBAL 4. Public getters and setters keep ?DateTimeInterface; see UPGRADE-3.2.md if your application checks instanceof \DateTime or calls ->modify() expecting in-place mutation. Fixes #438 and #439.
Added
- Automatic periodic cleanup via Symfony Scheduler: enable
gesdinet_jwt_refresh_token.cleanup_schedule(requiressymfony/scheduler) to scheduleClearExpiredRefreshTokensMessagewithout a system cron job. - Sessions CLI & family revocation:
bin/console gesdinet:jwt:sessions <username>(with--end=<family>) andbin/console gesdinet:jwt:revoke --family=<family>. - Audit events:
Event\RefreshTokenCreatedEventandEvent\RefreshTokenRevokedEventdispatched on token issuance, single-use rotation, and CLI revocation. - Symfony Profiler panel:
DataCollector\RefreshTokenDataCollectorand Web Debug Toolbar panel registered automatically whenkernel.debugistrue. - OpenAPI rate-limit docs:
OpenApi\OpenApiFactorynow documents429 Too Many Requests(withRetry-After) whenrate_limiteris enabled and preserves customPOSToperations already defined on acheck_path. - Opt-in session metadata:
Model\SessionMetadataAwareRefreshTokenInterfaceandModel\SessionMetadataTraitto recordlastUsedAt,ipAddress, anduserAgenton issued tokens and expose them onSession\Session. - Diagnostic command:
bin/console gesdinet:jwt:doctorto auditcheck_path,hash_tokens,single_use/reuse_detection,rate_limiter,dbal_auto_create_table, andcookie.secure.
Upgrade & Tooling
- Added UPGRADE-3.2.md and updated UPGRADE-RECTOR.md with
3.0 -> 3.1and3.1 -> 3.2checklists. - Verified against Symfony 8.1 and 8.2, PHP 8.4 and 8.5, 100% test coverage (681 tests, 1813 assertions), PHPStan level 10 (
bleedingEdge,strict-rules,type-coverage100%,cognitive-complexity), and Psalm taint analysis.