Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Passkeys Laravel Package

laravel/passkeys

Add passwordless WebAuthn/passkey authentication to Laravel. Install migrations, add a trait/contract to your User model, and use the @laravel/passkeys JS client for registration and login. Includes built-in routes for login, confirmation, and passkey management.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel-Native Integration: The package leverages Laravel’s Eloquent ORM, authentication guards, and middleware stack, ensuring seamless integration with existing Laravel applications. The PasskeyAuthenticatable trait and PasskeyUser contract align with Laravel’s conventions (e.g., Authenticatable trait), reducing architectural friction.
  • WebAuthn Compliance: Built on webauthn-lib (v5.3), the package adheres to FIDO2/CTAP standards, ensuring compliance with modern authentication protocols. The inclusion of a bundled AAGUID catalog simplifies authenticator identification without external dependencies.
  • Modular Design: Core logic is encapsulated in extensible actions (e.g., GenerateRegistrationOptions, VerifyPasskey), allowing customization without monolithic overrides. This fits well with Laravel’s service container and dependency injection patterns.
  • Event-Driven: Emits PasskeyRegistered, PasskeyVerified, and PasskeyDeleted events, enabling integration with Laravel’s event system (e.g., logging, analytics, or third-party notifications).

Integration Feasibility

  • Low-Coupling: Requires minimal changes to existing codebases:
    • Add PasskeyAuthenticatable trait to the User model (or implement PasskeyUser contract).
    • Publish migrations and config (one-time setup).
    • Integrate the @laravel/passkeys npm client for frontend flows.
  • Database Schema: Introduces a passkeys table with columns for WebAuthn credentials (id, user_handle, public_key, sign_count, transports, etc.). The schema is opinionated but flexible—custom models can extend the base Passkey class.
  • Frontend-Backend Sync: The npm client (@laravel/passkeys) handles WebAuthn ceremonies (registration/verification) via navigator.credentials, while the server package processes responses. This separation of concerns aligns with modern SPAs and Laravel APIs.

Technical Risk

  • WebAuthn Complexity: WebAuthn involves cryptographic operations and browser-specific quirks (e.g., platform vs. roaming authenticators). The package abstracts this but requires testing across browsers/devices (e.g., Safari, Chrome, Edge).
  • Database Transactions: Pessimistic locking for passkey verification assumes transaction support in the underlying database. Apps using SQLite (without WAL mode) or older MySQL versions may need adjustments.
  • Custom Model Pitfalls: While fixes for custom models exist (PR #14, #23), polymorphic relations or non-standard key names (e.g., auth_id instead of user_id) may still require overrides.
  • Middleware Dependencies: Passkey management routes use password.confirm middleware by default. Apps without password-based auth (e.g., API-only) may need to customize or disable this.
  • Deprecation Risk: The package is young (first release in 2024) but shows active maintenance. Monitor for breaking changes in webauthn-lib or Laravel compatibility.

Key Questions

  1. Authentication Guard: Does your app use a non-standard guard (e.g., api, sanctum)? If so, configure passkeys.guard in the config.
  2. Custom User Models: Are your user models polymorphic or use non-standard key names? Test with custom models early.
  3. Database Support: Does your DB support transactions and pessimistic locking? SQLite/WAL mode may be required.
  4. Frontend Framework: Are you using Laravel Blade, Inertia.js, or a custom SPA? The npm client works with all but may need adjustments for non-Laravel frontends.
  5. Legacy Browser Support: Do you need to support older browsers (e.g., Safari <15)? WebAuthn support varies.
  6. Multi-Tenancy: Are passkeys tenant-scoped? The package doesn’t natively support this; you’ll need to extend the Passkey model or add a tenant_id column.
  7. Audit Logging: Do you need detailed passkey event logs? Extend the events or bind a custom logger.
  8. Rate Limiting: Is throttle:6,1 sufficient for your traffic? Adjust passkeys.throttle or implement custom middleware.

Integration Approach

Stack Fit

  • Laravel Ecosystem: Optimized for Laravel 10+ with PHP 8.1+. Leverages:
    • Eloquent ORM for passkey storage.
    • Laravel’s authentication system (guards, sessions).
    • Blade/Inertia.js for frontend integration (via npm client).
  • Frontend Compatibility: The @laravel/passkeys npm package works with:
    • Blade: Direct integration with Laravel views.
    • Inertia.js: Pass props to React/Vue components.
    • Custom SPAs: Use the npm client with any framework (e.g., Next.js, Svelte).
  • API-First: Routes return JSON by default, enabling headless API usage (e.g., mobile apps, IoT devices).
  • Database Agnostic: Works with MySQL, PostgreSQL, SQLite (with WAL), and SQL Server, but transactions are required for pessimistic locking.

Migration Path

  1. Assessment Phase:
    • Audit existing auth flows (e.g., email/password, OAuth).
    • Identify high-risk users (e.g., admins, payment gateways) for passkey pilot.
    • Test with a non-production Laravel instance (e.g., staging).
  2. Pilot Phase:
    • Step 1: Integrate the npm client for passkey registration/verification.
    • Step 2: Add PasskeyAuthenticatable to the User model and publish migrations.
    • Step 3: Test login/management routes with a small user group.
    • Step 4: Customize middleware (e.g., restrict passkey management to admins).
  3. Rollout Phase:
    • Phased Adoption: Enable passkeys for specific user roles (e.g., admins first).
    • Fallback Mechanisms: Ensure email/password remains available during transition.
    • Monitoring: Track passkey success rates, errors, and user feedback.
  4. Optimization Phase:
    • Tune passkeys.throttle based on traffic patterns.
    • Extend events for analytics (e.g., PasskeyVerified → increment "secure logins" metric).
    • Customize responses (e.g., redirect to dashboard post-login).

Compatibility

  • Laravel Versions: Tested with Laravel 10+. May work with 9.x but not officially supported.
  • PHP Versions: Requires PHP 8.1+ (for named arguments, union types).
  • Browser Support: Relies on WebAuthn API (supported in Chrome 67+, Firefox 60+, Safari 15+, Edge 79+).
  • Database Drivers: Supports MySQL, PostgreSQL, SQLite (WAL mode), SQL Server. No MongoDB support.
  • Existing Auth: Coexists with Laravel’s default auth (e.g., Auth::attempt()). Passkeys replace or supplement email/password.
  • Third-Party Packages: No known conflicts with popular Laravel packages (e.g., Sanctum, Passport). Test with your stack.

Sequencing

  1. Prerequisites:
    • Upgrade to Laravel 10+ and PHP 8.1+ if not already.
    • Ensure database supports transactions (enable WAL mode for SQLite).
  2. Core Integration:
    • Install package: composer require laravel/passkeys.
    • Publish migrations/config: php artisan vendor:publish --tag=passkeys-migrations --tag=passkeys-config.
    • Add trait to User model: use PasskeyAuthenticatable.
  3. Frontend Setup:
    • Install npm client: npm install @laravel/passkeys.
    • Integrate registration/login flows (see README).
  4. Customization:
    • Override middleware (e.g., passkeys.management_middleware).
    • Extend actions/responses if needed (e.g., custom registration options).
  5. Testing:
    • Test with real devices (platform authenticators like Touch ID).
    • Verify edge cases (e.g., lost passkeys, concurrent logins).
  6. Deployment:
    • Run migrations: php artisan migrate.
    • Monitor logs for PasskeyRegistered/PasskeyVerified events.

Operational Impact

Maintenance

  • Dependency Updates: Monitor webauthn-lib and Laravel compatibility. The package uses pinned GitHub Actions SHAs (PR #21), reducing supply-chain risks.
  • Migration Safety: Migrations are backward-compatible within major versions. Downgrading may require data adjustments.
  • **
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle