thinkverse's avatar

Lumen Hash Config

Hello everybody, I've been playing around with Lumen for a bit, does anyone know how to change the hashing drivers on Lumen? I've tried adding a config option to the .env file, I've tried adding the config to the bootstrap/app.php file, I even tried to hard code the drivers but nothing works, the default is Bcrypt, I'm trying to make it use Argon instead, Illuminate has the drivers, I just can't switch them.

Anyone have any ideas?

0 likes
8 replies
bobbybouwmann's avatar

If you read carefully you can see that Lumen is using the Crypt::encrypt method which has nothing to do with the encryption from Laravel (bcrypt + argon).

This is class that's being used: https://github.com/laravel/framework/blob/e6c8aa0e39d8f91068ad1c299546536e9f25ef63/src/Illuminate/Encryption/Encrypter.php

I think you can use Laravel's hasher as well, as long as your register the hash facade and hash classes as well. If you register the following service provider you should be able to use Argon as well: https://github.com/laravel/framework/blob/5.8/src/Illuminate/Hashing/HashServiceProvider.php

Let me know if this works for you!

1 like
thinkverse's avatar

@BOBBYBOUWMANN - Yes, I know that Crypt::encrypt have nothing to do with Hash, I'm not using Crypt, I'm using the Hash Facades from Illuminate\Support\Facades\Hash, so I can use Hash::make, but I can't seem to change the drivers.

thinkverse's avatar

@BOBBYBOUWMANN - You can check out a simple version here; https://github.com/thinkverse/lumen-hash If you look at the basic route, you see that we can access the Hash::make via Illuminate, but it uses the standard bcrypt driver, I can't seem to figure out how to change the default driver to argon, I can use a service provider like you suggested, but this seems cleaner to me.

And yes, it's for use internally, I'm just writing it directly to the view so I can see what is returned.

thinkverse's avatar
thinkverse
OP
Best Answer
Level 15

Okay, so I've kind of solved it myself with the help of some googling. So by adding a Service Provider that scans a directory, I can add the Laravel hashing config to Lumen, and actually just use the Lavarel config to update the Hash drivers from bcrypt to argon, so if anyone ones to use the argon drivers instead of bcrypt on Lumen, check out the repository for a solution to that; https://github.com/thinkverse/lumen-hash

And yes, @BOBBYBOUWMANN you did point me in the right direction, thank you.

bobbybouwmann's avatar

@thinkverse Glad I could help! It's sad to see that Lumen doesn't come with this configurable option for encryption, but I also get it from the point of view of keeping it very lean and fast!

thinkverse's avatar

@BOBBYBOUWMANN - True, although from a security point of view, that's one config I think should've been included from the start.

Please or to participate in this conversation.