Customizing Laravel Authentication Hash

Asked

Viewed 123 times

1

Next, I have a specific database with specific columns and a specific Hash method, I am migrating to the following Laravel multi-tenancy structure.

I would like to know if there is any way to make the Standard ignore Bcrypt and accept my form of Hash?

If there is, how could I ?

1 answer

3


Just take a look at how the hashing standard works.

There is in the Illuminate\Hashing\HashServiceProvider the following method

public function register()
{
    $this->app->singleton('hash', function () { return new BcryptHasher; });
}

which means, by default, that you are using the BcryptHasher as an instance.

If you want to implement the hash alone, you will have to create your own service provider(Provider) and facades(Facades) for hashing and then swap the default file implementations config/app.php.

More precisely, you will want to trade in the array of providers

Illuminate\Hashing\HashServiceProvider::class, with your own service provider(providers), and the same goes for the array of aliases in the same file.

So, as an example, take a look at how the BcryptHasher implements an interface, and its hash implementation should implement the same interface.

That would extend the hash in Laravel.

Complementary topics

Change the hash used for logging in 5.4

Adding Custom User Providers

Custom auth and hashing Standard 5.1

Creating a Hashing Manager For Our Custom Laravel Hashing Implementations

Browser other questions tagged

You are not signed in. Login or sign up in order to post.