ecourty/token-bundle
Symfony bundle to manage secure, typed, revocable tokens for any Doctrine entity (password resets, email verification, share links). Supports expiry, single-use/max-uses, JSON payloads, events, subject resolution, and a purge command.
Feature Development:
password_reset tokens for a user after a security breach).Roadmap Priorities:
#[RequiresToken] attribute to support role-based token validation (e.g., only allow admin users to revoke tokens).Build vs. Buy:
TokenManager or TokenResolverInterface for niche use cases (e.g., IP-based token validation).Use Cases:
email_verify) with payloads (e.g., {"locale": "en"}).{"permissions": ["view", "edit"]}).TokenResolver).TokenConsumedEvent/TokenRevokedEvent.Adopt if:
password_reset vs. email_verify) and payloads (e.g., metadata like maxUses or permissions).#[RequiresToken] attribute).Look elsewhere if:
spomky-labs/token-refresher).predis/predis)."This package lets us standardize how we handle secure, time-limited tokens across the app—like password resets, email verifications, and shareable links—without building and maintaining custom logic. It reduces security risks (e.g., token reuse, expiration leaks) and cuts dev time by 30%+ for features like ‘magic links’ or ‘temporary access.’ The bundle’s event system also lets us hook into token actions for analytics or notifications, adding value without extra work. For example, we can automatically revoke all password reset tokens for a user after a breach, or track how often shareable links are used. It’s a low-risk, high-reward upgrade to our auth flow."
*"This Symfony bundle replaces our scattered token implementations (e.g., manual Doctrine queries, custom services) with a type-safe, race-condition-proof system. Key wins:
Token entity/table for all token types (password resets, verifications, shares).#[RequiresToken] to protect routes with minimal boilerplate, or extract tokens from headers/cookies via custom resolvers.php bin/console token:purge.maxUses, permissions) without schema changes.Migration path:
TokenManager.TokenSubjectInterface to your entities (e.g., User, Document).#[RequiresToken] for route protection.TokenCreatedEvent).Tradeoffs:
Next steps:
#[RequiresToken] for a high-traffic endpoint (e.g., /reset-password).How can I help you explore Laravel packages today?