selfsimilar/drupal7_password_hasher
PHP package for verifying and generating Drupal 7-compatible password hashes. Useful for migrating users to Laravel or other apps while preserving existing credentials, with support for Drupal’s phpass-based hashing format and validation against stored hashes.
user_pass() logic).Hash::make()) for new users.$account->pass format (e.g., :$salt:$hash).hautelook/phpass (more maintained) or Laravel’s Hash facade suffice?password_hash())?Hash facade to delegate Drupal 7 hashes to this package.retrieveByCredentials() to handle legacy hashes.UserSeeder or console command)./auth/drupal7/login).composer require selfsimilar/drupal7_password_hasher).Drupal7PasswordHasher) to abstract the package.use Selfsimilar\Drupal7PasswordHasher\Drupal7PasswordHasher as DrupalHasher;
class LaravelDrupalHasher implements HashInterface {
public function make($value, array $options = []): string {
return DrupalHasher::hash($value);
}
// Implement verify(), needs(), etc.
}
$this->app->bind(HashInterface::class, function ($app) {
return new LaravelDrupalHasher();
});
User::where('imported_from', 'drupal7')->each(function ($user) {
$user->password = DrupalHasher::hash($user->plain_password);
$user->save();
});
users.password fields.user module.user_pass()).function isDrupal7Hash(string $hash): bool {
return strpos($hash, ':') !== false; // Drupal 7 format: :$salt:$hash
}
user_pass_reset()).| Scenario | Impact | Mitigation |
|---|---|---|
| Incorrect salt format | Auth failures for imported users | Validate hashes pre-migration. |
| Package bugs | Hashing/verification errors | Fork and test edge cases. |
| Mixed hashing | Security risks if new users use Drupal 7 hashes | Enforce hasher per user source. |
| Drupal 7 deprecation | Future compatibility breaks | Plan to replace with modern hasher. |
:$salt:$hash vs. Laravel’s argon2id$...).How can I help you explore Laravel packages today?