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

Phpass Laravel Package

bordoni/phpass

Modernized, namespaced fork of Openwall Phpass (0.3) with Composer autoloading and unit tests. Provides PasswordHash for hashing and verifying passwords with minimal stylistic changes; public domain code, PHP 5 style.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Legacy System Alignment: Ideal for Laravel applications requiring Phpass-specific bcrypt hashing (e.g., migrating from hautelook/phpass or legacy systems). Misaligned for new projects where Laravel’s native Hash facade (using paragonie/bcrypt) is preferred.
  • Security Compliance: Meets OWASP/BCrypt standards but lacks modern features like Argon2 or adaptive cost factors. Compatible with GDPR/CCPA password storage requirements.
  • Laravel Ecosystem: Not a drop-in replacement for Laravel’s Hash facade; requires manual integration. Shadows Laravel’s Hash service if both are loaded.
  • Codebase Impact: Minimal changes needed for authentication flows (registration/login), but database schema must support Phpass hash format ($2a$...).

Integration Feasibility

  • Dependency Conflicts: Low risk (no external dependencies), but avoid mixing with paragonie/bcrypt or Laravel’s Hash in the same project.
  • Database Schema: Requires backward-compatible hash storage (e.g., varchar(255) for password column). Existing Laravel apps using Hash may need hash migration.
  • API Surface: Simple interface (HashPassword, CheckPassword) but no Laravel service provider integration by default.
  • Testing Overhead: Requires manual validation of hash migration paths and edge cases (e.g., malformed hashes).

Technical Risk

  • Deprecation Risk: No active maintenance (last release: 2022-05-27). Risk of PHP 8.2+ compatibility issues despite the PHP 8.1 fix.
  • Security Risk:
    • No updates for CVEs (e.g., bcrypt timing attacks).
    • Stuck on Phpass 0.3 (10+ years old), missing modern improvements (e.g., Argon2).
  • Functional Risk:
    • Hash incompatibility with Laravel’s Hash facade (cannot verify Phpass hashes with Hash::check).
    • No built-in password strength validation or multi-factor integration.
  • Performance Risk: No benchmarks against Laravel’s Hash; cost factor tuning may be required for production load.

Key Questions

  1. Why Phpass Over Laravel’s Hash?
    • Is this for legacy system migration (e.g., existing Phpass hashes) or a specific requirement (e.g., Phpass’s salt scheme)?
    • Could Laravel’s Hash facade (or paragonie/bcrypt) achieve the same goals with lower risk?
  2. PHP Version Support
    • Will this run on PHP 8.2+? If not, what’s the upgrade path (e.g., polyfills, forks)?
  3. Maintenance Strategy
    • How will security patches be applied if the package stagnates?
    • Is there a fallback plan (e.g., switching to Laravel’s Hash) if Phpass breaks?
  4. Hash Migration
    • How will existing passwords (if any) be converted to Phpass format?
    • Will this require a database downtime or dual-write phase?
  5. Performance Tradeoffs
    • Has the cost factor (8) been benchmarked for production load?
    • Are there plans to monitor hashing latency post-deployment?

Integration Approach

Stack Fit

  • Laravel Version Compatibility:
    • Supported: Laravel 8/9 (PHP 7.4–8.1) via Composer.
    • Unsupported: Laravel 10+ (PHP 8.2+) without testing or polyfills.
  • Dependency Conflicts:
    • None critical, but avoid mixing with:
      • Laravel’s Hash facade (hash format mismatch).
      • paragonie/bcrypt (duplicate bcrypt implementations).
  • Service Provider Integration:
    • Manual binding required (no built-in Laravel service provider).
    • Example:
      // app/Providers/AppServiceProvider.php
      $this->app->singleton(PasswordHash::class, function () {
          return new \Hautelook\Phpass\PasswordHash(config('hash.cost'), false);
      });
      
  • Configuration:
    • Add to config/app.php under aliases (optional):
      'Phpass' => \Hautelook\Phpass\PasswordHash::class,
      

Migration Path

  1. Phase 1: Dependency Addition

    • Add to composer.json:
      "require": {
          "bordoni/phpass": "^0.3.6"
      }
      
    • Run composer update bordoni/phpass --with-dependencies.
  2. Phase 2: Authentication Flow Updates

    • Registration:
      // Old (Laravel Hash)
      $hash = Hash::make($request->password);
      
      // New (Phpass)
      $hasher = app(PasswordHash::class);
      $hash = $hasher->HashPassword($request->password);
      
    • Login:
      // Old
      if (Hash::check($request->password, $user->password)) { ... }
      
      // New
      $hasher = app(PasswordHash::class);
      if ($hasher->CheckPassword($request->password, $user->password)) { ... }
      
  3. Phase 3: Database Schema Validation

    • Ensure password column in users table:
      • Type: varchar(255) (Phpass hashes are ~60 chars).
      • Example hash: $2a$08$....
    • Migration Example:
      Schema::table('users', function (Blueprint $table) {
          $table->string('password')->nullable()->change();
      });
      
  4. Phase 4: Hash Backfill (If Migrating)

    • For existing users, rehash passwords using Phpass:
      $users = User::all();
      $hasher = app(PasswordHash::class);
      foreach ($users as $user) {
          $user->password = $hasher->HashPassword($user->password); // Plaintext risk! Avoid.
          $user->save();
      }
      
    • Critical: Never store plaintext passwords. Use a secure migration tool or one-time script.
  5. Phase 5: Deprecate Laravel’s Hash (Optional)

    • Remove Hash facade from config/app.php if fully transitioning to Phpass.

Compatibility

  • PHP 8.1+: Patched for intval deprecation (PR #5), but untested on 8.2+.
  • Laravel Services:
    • No integration with Laravel’s Hash service provider.
    • Manual binding required (see above).
  • Hash Format:
    • Output: $2a$08$... (Phpass-specific).
    • Input: Must match Phpass format; cannot verify with Laravel’s Hash::check.
  • Edge Cases:
    • Portable hashes: Set true in PasswordHash(8, true) for compatibility, but avoid unless necessary (reduces security).

Sequencing

  1. Staging Environment:
    • Test Phpass integration in a non-production Laravel instance.
    • Validate hash generation/verification for 100+ test cases (including edge cases).
  2. Feature Flag:
    • Roll out Phpass behind a feature flag (e.g., config('auth.use_phpass')) for gradual migration.
  3. Database Migration:
    • Backfill hashes during low-traffic periods.
    • Monitor failed logins post-migration (indicates hash mismatches).
  4. Deprecation:
    • Phase out Laravel’s Hash facade only after full validation.

Operational Impact

Maintenance

  • Vendor Risk:
    • No active maintenance: Last release in 2022; no security patches expected.
    • Mitigation:
      • Monitor for PHP 8.2+ breakage.
      • Plan to migrate to Laravel’s Hash if Phpass becomes unsustainable.
  • Dependency Updates:
    • Manual intervention required for PHP version bumps.
    • No Composer autoupdates (use ^0.3.6 to avoid breaking changes).
  • Security Updates:
    • No process for bcrypt algorithm improvements (e.g., Argon2).
    • Workaround: Monitor OWASP/BCrypt for updates and manually fork if needed.

Support

  • Debugging Challenges:
    • Limited community support (24 stars, no active issues).
    • No Laravel-specific documentation (self-service troubleshooting required).
  • Common Issues:
    • Hash format mismatches (e.g., mixing Phpass and Laravel
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky